Problem
Required environment variables (DATABASE_URL, QF_CLIENT_SECRET, AI provider keys such as ANTHROPIC_API_KEY/GEMINI_API_KEY, etc.) are read ad hoc wherever they're needed across the codebase, with no single validation step at boot.
Proposed fix
Add a small lib/env.ts (or similar) module that validates all required env vars once at startup (e.g. via a schema library already in the dependency tree, or a plain assertion module) and throws a clear, actionable error immediately if one is missing or malformed.
Why this matters
Today a missing/misconfigured env var surfaces as an opaque runtime failure deep inside a request handler, rather than a clear boot-time error — this makes misconfiguration in new environments (local dev, staging, a new deploy target) much harder to diagnose than it needs to be.
Problem
Required environment variables (
DATABASE_URL,QF_CLIENT_SECRET, AI provider keys such asANTHROPIC_API_KEY/GEMINI_API_KEY, etc.) are read ad hoc wherever they're needed across the codebase, with no single validation step at boot.Proposed fix
Add a small
lib/env.ts(or similar) module that validates all required env vars once at startup (e.g. via a schema library already in the dependency tree, or a plain assertion module) and throws a clear, actionable error immediately if one is missing or malformed.Why this matters
Today a missing/misconfigured env var surfaces as an opaque runtime failure deep inside a request handler, rather than a clear boot-time error — this makes misconfiguration in new environments (local dev, staging, a new deploy target) much harder to diagnose than it needs to be.