32 lines
819 B
JavaScript
32 lines
819 B
JavaScript
import express from "express";
|
|
import path from "path";
|
|
import fs from "fs";
|
|
import { fileURLToPath } from "url";
|
|
import updateLink from "./updatelink.js";
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
const app = express();
|
|
const PORT = 4000;
|
|
|
|
updateLink().catch((err) => {
|
|
console.error("Errore:", err);
|
|
});
|
|
|
|
// Serve lista app da apps.json
|
|
app.get("/apps", (req, res) => {
|
|
const apps = JSON.parse(fs.readFileSync(path.join(__dirname, "apps.json")));
|
|
res.json(apps);
|
|
});
|
|
|
|
// Serve frontend build
|
|
app.use(express.static(path.join(__dirname, "../frontend/dist")));
|
|
|
|
app.get("*", (req, res) => {
|
|
res.sendFile(path.join(__dirname, "../frontend/dist/index.html"));
|
|
});
|
|
|
|
app.listen(PORT, () => {
|
|
console.log(`Dashboard running on http://localhost:${PORT}`);
|
|
});
|