Hugging Face Deployer
Deploy bot to Hugging Face Spaces
03b405b
Raw History Blame Contribute Delete
724 Bytes
const express = require("express");
const path = require("node:path");
const { paths } = require("../config/paths");
const { snapshot } = require("../monitoring/metrics");
const { listJobs, listEvents } = require("../queue/jobs");
function createDashboardServer() {
const app = express();
app.use(express.static(paths.dashboardPublic));
app.get("/api/status", async (_req, res) => res.json(await snapshot()));
app.get("/api/queue", (_req, res) => res.json({ jobs: listJobs(100) }));
app.get("/api/logs", (_req, res) => res.json({ events: listEvents(200) }));
app.get("*", (_req, res) => res.sendFile(path.join(paths.dashboardPublic, "index.html")));
return app;
}
module.exports = { createDashboardServer };