feat(HAI-002): update Express server to serve Vite build output

This commit is contained in:
Dustin Byrne
2026-03-25 18:26:37 -04:00
parent e5caa540c2
commit e0746fb387

View File

@@ -0,0 +1,28 @@
import express from "express";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import type { TaskStore } from "@hai/core";
import { createApiRoutes } from "./routes.js";
import { createSSE } from "./sse.js";
const __dirname = dirname(fileURLToPath(import.meta.url));
export function createServer(store: TaskStore) {
const app = express();
app.use(express.json());
app.use(express.static(join(__dirname, "..", "client")));
// SSE endpoint
app.get("/api/events", createSSE(store));
// REST API
app.use("/api", createApiRoutes(store));
// SPA fallback
app.get("/{*splat}", (_req, res) => {
res.sendFile(join(__dirname, "..", "client", "index.html"));
});
return app;
}