Skip to content

Feat/unify env file resolution#376

Merged
kilodesodiq-arch merged 5 commits into
ChainForgee:mainfrom
Opulencechuks:feat/unify-env-file-resolution
Jul 17, 2026
Merged

Feat/unify env file resolution#376
kilodesodiq-arch merged 5 commits into
ChainForgee:mainfrom
Opulencechuks:feat/unify-env-file-resolution

Conversation

@Opulencechuks

Copy link
Copy Markdown
Contributor

Closes #255

Summary

Unifies environment file resolution and loading logic between main.ts and app.module.ts to eliminate drift in .env lookup paths.

Introduced a central helper loadEnv() in src/common/utils/env-loader.ts to coordinate search candidates deterministically. The helper enforces that .env file values take precedence over OS environment variables (dotenv always wins over the OS env).

Testing

A new test suite was created under src/common/utils/__tests__/env-loader.spec.ts asserting that:

  1. Candidate search paths match the canonical priority.
  2. The honest precedence rule (dotenv overrides OS env) is respected.
  3. Both direct loadEnv() calls (the main.ts path) and NestJS module initialization (the app.module.ts path) agree on the final environment state.
bun test app/backend/src/common/utils/__tests__/env-loader.spec.ts

Screenshots

N/A (Backend changes only)

Checklist

  • Tests added or updated for new/changed behavior
  • Existing tests pass
  • No secrets, keys, or seed phrases committed
  • Follows the coding conventions in the relevant service README
  • PR is focused on a single concern

Copy link
Copy Markdown
Contributor

Awesome work on this! Thanks for the contribution 🚀 Merging now.

@kilodesodiq-arch
kilodesodiq-arch merged commit 6cc7111 into ChainForgee:main Jul 17, 2026
8 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.

Move env-file loading into a shared helper

2 participants