import { existsSync } from "node:fs"; import { fileURLToPath } from "node:url"; import { buildApp } from "./app"; import { loadConfig } from "./config"; // Local development reads the repo-root .env; deployments set real env vars. const envFile = fileURLToPath(new URL("../../../.env", import.meta.url)); if (existsSync(envFile)) process.loadEnvFile(envFile); const config = loadConfig(process.env); const app = buildApp(config); try { await app.listen({ host: "0.0.0.0", port: config.port }); } catch (error) { app.log.error(error); process.exit(1); }