import "./telemetry/otel"; import { NestFactory } from "@nestjs/core"; import { Module } from "@nestjs/common"; import { AppModule } from "./app.module"; import { FeedsModule } from "./feeds/feeds.module"; import { ArchiveModule } from "./archive/archive.module"; import { logger } from "./telemetry/logger"; @Module({ imports: [AppModule, ArchiveModule, FeedsModule] }) class RootModule {} /** Browser origins allowed to call the API (comma-separated). Defaults cover the dev web server on :3001. */ function corsOrigins(): string[] { const configured = process.env.CORS_ORIGINS; if (configured !== undefined && configured.trim() !== "") return configured.split(",").map((o) => o.trim()); return ["http://localhost:3001", "http://127.0.0.1:3001", "http://localhost:3000", "http://127.0.0.1:3000"]; } async function bootstrap(): Promise { const app = await NestFactory.create(RootModule, { logger: ["error", "warn"], abortOnError: false, }); // Sessions use bearer tokens; OAuth callbacks also bind the initiating browser with an HttpOnly cookie. app.enableCors({ origin: corsOrigins(), credentials: true, methods: ["GET", "POST", "PATCH", "DELETE"], allowedHeaders: ["Authorization", "Content-Type"], }); const port = Number(process.env.PORT ?? 3000); app.enableShutdownHooks(); await app.listen(port); logger.info({ port }, "api listening"); } void bootstrap().catch((error: unknown) => { console.error("api bootstrap failed", error); process.exitCode = 1; });