export const config = { env: process.env.NODE_ENV ?? "development", port: Number(process.env.API_PORT ?? 8221), host: process.env.API_HOST ?? "127.0.0.1", webUrl: (process.env.WEB_URL ?? process.env.NEXT_PUBLIC_SITE_URL ?? "http://localhost:8220").replace(/\/$/, ""), redisUrl: process.env.REDIS_URL ?? "", internalToken: process.env.INTERNAL_SERVICE_TOKEN ?? "", logLevel: process.env.LOG_LEVEL ?? "info", /** Store response bodies for playground inspection (never for API by default). */ storeBodies: process.env.FETCHA_STORE_BODIES === "1", healthProbeIntervalMs: Number(process.env.HEALTH_PROBE_INTERVAL_MS ?? 5 * 60_000), maxResponseBytesDefault: Number(process.env.MAX_RESPONSE_BYTES ?? 20_000_000), /** Multiplier over upstream cost used for customer pricing when a plan has no explicit unit price. */ defaultMargin: Number(process.env.FETCHA_DEFAULT_MARGIN ?? 2.5), version: process.env.FETCHA_VERSION ?? "0.1.0", } as const; export function assertProductionConfig(): void { if (config.env !== "production") return; const missing: string[] = []; if (!process.env.DATABASE_URL) missing.push("DATABASE_URL"); if (!config.internalToken || config.internalToken === "change-me") missing.push("INTERNAL_SERVICE_TOKEN"); if (missing.length) throw new Error(`Missing required production configuration: ${missing.join(", ")}`); }