Files
Cibello-app/apps/api/src/index.ts
T
2026-08-05 19:21:11 +07:00

22 lines
646 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { loadConfig } from "./config.js";
import { buildServer } from "./server.js";
const config = loadConfig();
const app = await buildServer(config);
const shutdown = async (signal: string) => {
app.log.info(`${signal} mottagen stänger ner API:t.`);
await app.close();
process.exit(0);
};
process.on("SIGTERM", () => void shutdown("SIGTERM"));
process.on("SIGINT", () => void shutdown("SIGINT"));
try {
await app.listen({ port: config.API_PORT, host: "0.0.0.0" });
app.log.info(`API igång på :${config.API_PORT} (${config.NODE_ENV}, AAMOS=${config.AAMOS_MODE})`);
} catch (err) {
app.log.error(err);
process.exit(1);
}