Problem
.env.example defines large per-network variable groups (TESTNET_*, MAINNET_*, DEVNET_* for database, read replica, RPC, RPC WS, Horizon, passphrase, API subdomain) plus indexer tuning vars. There is no fail-fast validation, so a missing or misnamed variable surfaces as a deep runtime error on the first request that needs it rather than at boot. zod is already a dependency and is well suited to this.
What needs to be done
- Add a startup config validator (using
zod) that checks all required variables for the selected network (STELLAR_NETWORK/NODE_ENV) and exits with a clear message listing missing/invalid vars.
- Apply it to both the API service (
src/index.ts) and the indexer entrypoint.
- Document the required variables per network in the README, and confirm the
TESTNET_* set matches the live testnet deployment.
Files
- new
src/config/validateEnv.ts (and indexer equivalent)
src/index.ts, indexer/src/index.js/config.js
.env.example, README.md
Acceptance deliverables
- Starting either service with a missing required variable fails immediately with a clear, actionable message.
- README documents required variables per network.
Tests to pass
- Unit test: validator passes with a complete env and throws listing the missing keys with an incomplete env.
Problem
.env.exampledefines large per-network variable groups (TESTNET_*,MAINNET_*,DEVNET_*for database, read replica, RPC, RPC WS, Horizon, passphrase, API subdomain) plus indexer tuning vars. There is no fail-fast validation, so a missing or misnamed variable surfaces as a deep runtime error on the first request that needs it rather than at boot.zodis already a dependency and is well suited to this.What needs to be done
zod) that checks all required variables for the selected network (STELLAR_NETWORK/NODE_ENV) and exits with a clear message listing missing/invalid vars.src/index.ts) and the indexer entrypoint.TESTNET_*set matches the live testnet deployment.Files
src/config/validateEnv.ts(and indexer equivalent)src/index.ts,indexer/src/index.js/config.js.env.example,README.mdAcceptance deliverables
Tests to pass