From 02d69fa491cfa80690e713b7c409ede90a8112f6 Mon Sep 17 00:00:00 2001 From: jason Date: Sat, 7 Mar 2026 22:59:13 -0600 Subject: [PATCH] feat: add backend Express server with API and static serving --- backend/src/index.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 backend/src/index.ts diff --git a/backend/src/index.ts b/backend/src/index.ts new file mode 100644 index 0000000..4c653d0 --- /dev/null +++ b/backend/src/index.ts @@ -0,0 +1,26 @@ +import express from "express"; +import cors from "cors"; +import path from "path"; +import imageRoutes from "./routes/image"; + +const app = express(); +const port = process.env.PORT || 3000; + +app.use(cors()); +app.use(express.json()); + +// API routes +app.use("/api", imageRoutes); + +// Serve frontend static build +const publicDir = path.join(__dirname, "public"); +app.use(express.static(publicDir)); + +// Fallback to index.html for SPA routing +app.get("*", (_req, res) => { + res.sendFile(path.join(publicDir, "index.html")); +}); + +app.listen(port, () => { + console.log(`Server listening on port ${port}`); +}); \ No newline at end of file