15 lines
617 B
JavaScript
15 lines
617 B
JavaScript
// Точка входа продукта: `node product/server.mjs`. Слушает $PORT, отвечает 200 на GET /healthz.
|
|
import { createServer } from "node:http";
|
|
import { handle } from "./lib/http.mjs";
|
|
import { routes } from "./routes.mjs";
|
|
|
|
const port = Number(process.env.PORT ?? 3000);
|
|
|
|
createServer((req, res) => {
|
|
handle(routes, req, res).catch((e) => {
|
|
console.error(e);
|
|
if (!res.headersSent) res.writeHead(500, { "content-type": "text/plain; charset=utf-8" });
|
|
res.end("Внутренняя ошибка");
|
|
});
|
|
}).listen(port, "0.0.0.0", () => console.log(`product on :${port}`));
|