Skip to content

Externalize and validate environment configuration in config/env with fail-fast checks #359

@thlpkee20-wq

Description

@thlpkee20-wq

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
    • npm test
  • 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

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions