feat: validate required env vars at startup #144

Merged
pook merged 2 commits from feat/startup-env-validation into main 2026-04-09 06:14:28 -04:00
Owner

Summary

  • Adds enforceEnv() startup check in packages/api/src/env.ts that validates OPENAI_API_KEY, DATABASE_URL, and STRIPE_SECRET_KEY before any server initialization
  • Logs all missing vars (not just the first) and calls process.exit(1) if any are absent
  • Unit test covers: all vars set, single var missing, and all vars missing

Closes #114, replaces #54.

Test plan

  • bun test packages/api/tests/unit/env.test.ts — 3/3 pass
  • Manual: start server without env vars, verify it exits with clear error listing all missing vars
  • Manual: start server with all env vars, verify it boots normally

🤖 Generated with Claude Code

## Summary - Adds `enforceEnv()` startup check in `packages/api/src/env.ts` that validates `OPENAI_API_KEY`, `DATABASE_URL`, and `STRIPE_SECRET_KEY` before any server initialization - Logs **all** missing vars (not just the first) and calls `process.exit(1)` if any are absent - Unit test covers: all vars set, single var missing, and all vars missing Closes #114, replaces #54. ## Test plan - [x] `bun test packages/api/tests/unit/env.test.ts` — 3/3 pass - [ ] Manual: start server without env vars, verify it exits with clear error listing all missing vars - [ ] Manual: start server with all env vars, verify it boots normally 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Adds enforceEnv() check that runs before any server initialization.
If OPENAI_API_KEY, DATABASE_URL, or STRIPE_SECRET_KEY is missing,
logs all missing vars and exits with code 1.

Closes #114, replaces #54.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
pook merged commit 341c27aada into main 2026-04-09 06:14:26 -04:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot!144
No description provided.