- npm audit fix (multer 2.5.0, body-parser, qs, proxy-addr): 0 vulnerabilities - engines node >=22.9 and .nvmrc (prod runs Node 26) - GET /healthz for deployment checks - workflow: check job (npm ci, npm test, npm audit) on every push; deploy only on main after checks, with pinned host key, BatchMode and exact commit SHA - ops/deploy-gameservers-control.sh: lock, refuse dirty tree, fast-forward to the commit, npm ci --omit=dev, wait for /healthz, roll back on failure - stop tracking storage/servers.json (prod storage now lives outside the repo) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
964 B
JavaScript
29 lines
964 B
JavaScript
import express from "express";
|
|
import path from "node:path";
|
|
import { config } from "./config.js";
|
|
import { requireAdmin, requireAuth } from "./middlewares/auth.js";
|
|
import { adminRouter } from "./routes/admin.js";
|
|
import { authRouter } from "./routes/auth.js";
|
|
import { logsRouter } from "./routes/logs.js";
|
|
import { serversRouter } from "./routes/servers.js";
|
|
|
|
function createApp() {
|
|
const app = express();
|
|
app.use(express.json());
|
|
app.get("/healthz", (_req, res) => res.json({ ok: true }));
|
|
app.use("/server-images", express.static(config.serverImagesDir));
|
|
|
|
app.use("/api", authRouter);
|
|
app.use("/api", requireAuth, serversRouter);
|
|
app.use("/api", requireAuth, requireAdmin, logsRouter);
|
|
app.use("/api/admin", requireAuth, requireAdmin, adminRouter);
|
|
|
|
app.use(express.static(config.publicDir));
|
|
app.get("/{*splat}", (_req, res) => {
|
|
res.sendFile(path.join(config.publicDir, "index.html"));
|
|
});
|
|
|
|
return app;
|
|
}
|
|
|
|
export { createApp };
|