Glad to see someone else had the same requirements in regards to managing environments and environment variables in NestJS.
What we ended up using was nest-typed-config with its multiple loaders approach.
Basically we have 4 different config files:
base.yml (shared across all environments)
development.yml
test.yml
production.yml
We still leverage the env var loader with highest precedence to adhere to 12factor principles, while providing sane defaults to ease the setup and being developer friendly.
Petros Kyriakou yes exactly, also doing validation/transformation through class-validator/class-transformer, but validation is also possible in the official NestJS config module through Joi like you outlined in your great article :)
Benjamin Klotz
Glad to see someone else had the same requirements in regards to managing environments and environment variables in NestJS. What we ended up using was nest-typed-config with its multiple loaders approach.
Basically we have 4 different config files:
We still leverage the env var loader with highest precedence to adhere to 12factor principles, while providing sane defaults to ease the setup and being developer friendly.