SPB Git forge

spb/fetcha

Public
11commits 1branches 0releases
1.5 MBsize
maindefault branch
16 days agolast push
TypeScript 97.5% SQL 1.4% Python 0.8%
1.3 KB · 25 lines typescript
Raw Blame History
1export const config = {2  env: process.env.NODE_ENV ?? "development",3  port: Number(process.env.API_PORT ?? 8221),4  host: process.env.API_HOST ?? "127.0.0.1",5  webUrl: (process.env.WEB_URL ?? process.env.NEXT_PUBLIC_SITE_URL ?? "http://localhost:8220").replace(/\/$/, ""),6  redisUrl: process.env.REDIS_URL ?? "",7  internalToken: process.env.INTERNAL_SERVICE_TOKEN ?? "",8  logLevel: process.env.LOG_LEVEL ?? "info",9  /** Store response bodies for playground inspection (never for API by default). */10  storeBodies: process.env.FETCHA_STORE_BODIES === "1",11  healthProbeIntervalMs: Number(process.env.HEALTH_PROBE_INTERVAL_MS ?? 5 * 60_000),12  maxResponseBytesDefault: Number(process.env.MAX_RESPONSE_BYTES ?? 20_000_000),13  /** Multiplier over upstream cost used for customer pricing when a plan has no explicit unit price. */14  defaultMargin: Number(process.env.FETCHA_DEFAULT_MARGIN ?? 2.5),15  version: process.env.FETCHA_VERSION ?? "0.1.0",16} as const;1718export function assertProductionConfig(): void {19  if (config.env !== "production") return;20  const missing: string[] = [];21  if (!process.env.DATABASE_URL) missing.push("DATABASE_URL");22  if (!config.internalToken || config.internalToken === "change-me") missing.push("INTERNAL_SERVICE_TOKEN");23  if (missing.length) throw new Error(`Missing required production configuration: ${missing.join(", ")}`);24}25