import express from "express"; import { json } from "body-parser"; import path from "path"; import { registerApiRoutes } from "./api"; export async function createApp() { const app = express(); app.use(json()); registerApiRoutes(app); // In production, serve the built admin UI if (process.env.NODE_ENV === "production") { const adminDist = path.join(__dirname, "../../admin/dist"); app.use(express.static(adminDist)); app.get("/*", (_req, res) => { res.sendFile(path.join(adminDist, "index.html")); }); } return app; }