Description
src/config/env.ts centralizes environment configuration, but several modules read process.env directly (for example STELLAR_SERVER_SECRET in src/services/stellarSubmissionService.ts, API_VERSION_PREFIX and PORT in src/index.ts). Centralize all configuration access through a validated env schema that fails fast at startup when required secrets are missing, and document each variable.
Requirements and context
- Must be secure, tested, and documented
- Should be efficient and easy to review
- Relevant code:
src/config/env.ts, src/services/stellarSubmissionService.ts, src/index.ts
- Missing required secrets must abort startup with a redacted, actionable error
Suggested execution
- Fork the repo and create a branch
git checkout -b feat/env-config-fail-fast
- Implement changes
- Define a Zod env schema in
src/config/env.ts covering JWT, Stellar, DB, CORS vars
- Replace direct
process.env reads in submission service and index with the validated env
- Add a documented table of required/optional variables
- Validate security and correctness assumptions
Test and commit
- Run tests
- Cover edge cases
- Missing secret aborts, invalid URL rejected, defaults applied, secrets never logged
- Include test output and notes
Example commit message
feat: validate and centralize environment configuration
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
src/config/env.tscentralizes environment configuration, but several modules readprocess.envdirectly (for exampleSTELLAR_SERVER_SECRETinsrc/services/stellarSubmissionService.ts,API_VERSION_PREFIXandPORTinsrc/index.ts). Centralize all configuration access through a validated env schema that fails fast at startup when required secrets are missing, and document each variable.Requirements and context
src/config/env.ts,src/services/stellarSubmissionService.ts,src/index.tsSuggested execution
git checkout -b feat/env-config-fail-fastsrc/config/env.tscovering JWT, Stellar, DB, CORS varsprocess.envreads in submission service and index with the validatedenvTest and commit
npm testExample commit message
feat: validate and centralize environment configurationGuidelines