import http from "node:http"; import fs from "node:fs"; import path from "node:path"; const port = Number(process.env.WEB_PORT ?? process.env.PORT ?? 3000); const appName = process.env.APP_NAME ?? "HexaHost GameCloud"; const publicDir = path.join(process.cwd(), "public"); const indexHtml = ` ${appName}

${appName}

Phase 0 — Web stub. Next.js UI arrives in Phase 1.

`; const server = http.createServer((req, res) => { if (req.url === "/api/health") { res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({ status: "ok", service: "web", phase: "0" })); return; } if (req.url === "/" || req.url === "/index.html") { const filePath = path.join(publicDir, "index.html"); if (fs.existsSync(filePath)) { res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }); fs.createReadStream(filePath).pipe(res); return; } res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }); res.end(indexHtml); return; } res.writeHead(404, { "Content-Type": "application/json" }); res.end(JSON.stringify({ status: "not_found" })); }); server.listen(port, () => { console.log(JSON.stringify({ level: "info", msg: "web listening", port })); });