// server/_core/static.ts import express from "express"; import fs from "fs"; import path from "path"; import { fileURLToPath } from "url"; function serveStatic(app) { const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const distPath = path.resolve(__dirname, "public"); if (!fs.existsSync(distPath)) { console.error( `[Static] Could not find build directory: ${distPath}` ); console.error(`[Static] Make sure to run 'pnpm build' first`); app.use("*", (_req, res) => { res.status(503).send("Service starting up, please wait..."); }); return; } console.log(`[Static] Serving files from: ${distPath}`); app.use(express.static(distPath)); app.use("*", (_req, res) => { res.sendFile(path.resolve(distPath, "index.html")); }); } export { serveStatic };