Files
pocket-pascal/server/src/index.ts
2026-08-04 13:25:32 +00:00

39 lines
1.0 KiB
TypeScript

import express from "express"
import fs from "node:fs"
import path from "node:path"
import { fileURLToPath } from "node:url"
import { helloRouter } from "./routes/hello.js"
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const app = express()
const PORT = process.env.PORT ? Number(process.env.PORT) : 3001
app.use(express.json())
app.get("/api/health", (_req, res) => {
res.json({ ok: true })
})
app.use("/api", helloRouter)
// In production, serve the built client (client/dist) and fall back to index.html.
const clientDist = path.resolve(__dirname, "../../client/dist")
if (fs.existsSync(clientDist)) {
app.use(express.static(clientDist))
app.get("*", (_req, res) => {
res.sendFile(path.join(clientDist, "index.html"))
})
}
app.listen(PORT, () => {
console.log(`Pocket Pascal server listening on http://localhost:${PORT}`)
})
// deploy test Tue Aug 4 13:19:10 UTC 2026
// deploy test 1785849660
// deploy test 1785849758
// deploy test 1785849825
// final deploy test 1785849887
// deploy after ProtectSystem fix 1785849932