Skip to content

feat(backend): Add configuration validation#170

Merged
Smartdevs17 merged 2 commits intoSmartdevs17:mainfrom
activatedkc:feature/backend-env-validation
Mar 29, 2026
Merged

feat(backend): Add configuration validation#170
Smartdevs17 merged 2 commits intoSmartdevs17:mainfrom
activatedkc:feature/backend-env-validation

Conversation

@activatedkc
Copy link
Copy Markdown
Contributor

Problem

Missing environment variables cause runtime errors in the backend, often only discovered when a specific service (like AI verification) is invoked.

Proposed Solution

Implemented centralized environment variable validation at application startup using Zod.

  • Centralized Config: Added backend/src/config/env.ts to define the environment schema and defaults.
  • Startup Validation: The backend now validates all required variables (specifically OPENAI_API_KEY) immediately upon starting. If validation fails, the process exits with a clear error message.
  • Typed Configuration: Refactored stellar, verification, and invoice services to use a unified, typed config() object instead of raw process.env calls.
  • Documentation: Updated ENV_VARS.md and .env.example to clearly state which variables are required.

Acceptance Criteria

  • Check required env vars on startup
  • Return clear error messages for missing vars
  • Document required variables

Technical Notes

  • New File: backend/src/config/env.ts
  • Modified Files:
    • backend/src/index.ts
    • backend/src/services/stellar.ts
    • backend/src/services/verification.ts
    • backend/src/services/invoice.ts
    • ENV_VARS.md
    • backend/.env.example

Fixes #20

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 28, 2026

@activatedkc is attempting to deploy a commit to the smartdevs17's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 28, 2026

@activatedkc Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@activatedkc
Copy link
Copy Markdown
Contributor Author

Kindly review @Smartdevs17

@activatedkc
Copy link
Copy Markdown
Contributor Author

The PR is ready for review @Smartdevs17

@Smartdevs17
Copy link
Copy Markdown
Owner

merge conflict bro

@Smartdevs17 Smartdevs17 merged commit 2239576 into Smartdevs17:main Mar 29, 2026
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backend: Add configuration validation

2 participants