27 lines
702 B
TypeScript
27 lines
702 B
TypeScript
import http from "node:http";
|
|
|
|
const port = Number(process.env.API_PORT ?? 3001);
|
|
const appName = process.env.APP_NAME ?? "HexaHost GameCloud";
|
|
|
|
const server = http.createServer((req, res) => {
|
|
if (req.url === "/healthz" || req.url === "/health") {
|
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
res.end(
|
|
JSON.stringify({
|
|
status: "ok",
|
|
service: "api",
|
|
app: appName,
|
|
phase: "0",
|
|
}),
|
|
);
|
|
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: "api listening", port }));
|
|
});
|