Skip to content

fix: load and validate required env vars at startup (#24)#30

Merged
ayshadogo merged 1 commit intoDfunder:mainfrom
Chucks1093:fix-env-config-24
Mar 9, 2026
Merged

fix: load and validate required env vars at startup (#24)#30
ayshadogo merged 1 commit intoDfunder:mainfrom
Chucks1093:fix-env-config-24

Conversation

@Chucks1093
Copy link
Contributor

Closes #24

Changes

  • Added dotenvy crate to load environment variables from .env at startup.
  • Added a new config module at src/config.rs with:
    • Config struct
    • Config::from_env() loader
    • Required variable checks for:
      • STELLAR_NETWORK
      • STELLAR_PLATFORM_SECRET
      • HORIZON_URL
      • SOROBAN_RPC_URL
    • Descriptive errors for missing and empty required variables.
  • Updated startup flow in src/main.rs to:
    • load and validate config at process start
    • print Startup configuration error: ... and exit with code 1 if invalid
  • Updated .env.example with all required keys and clear descriptions.
  • Updated Cargo.lock for new dependency resolution.

Testing

  • Ran cargo test in repository root.
  • Result: all tests passing (41 passed, 0 failed).

Acceptance Criteria Check

  • Service now fails at startup with a clear message when any required env var is missing.
  • Required env vars are loaded and validated at startup.
  • .env.example includes all required keys with descriptions.

@ayshadogo ayshadogo merged commit 8f119e6 into Dfunder:main Mar 9, 2026
3 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.

Environment Variable Management with dotenvy

2 participants