Nikaple / nest-typed-config

Intuitive, type-safe configuration module for Nest framework ✨
MIT License
204 stars 25 forks source link

Use arbitrary ENV variable for file loading #500

Closed alexey-shakura closed 9 months ago

alexey-shakura commented 9 months ago

I'm submitting a...

Current behavior

I would like to use fileLoader but NODE_ENV is hardcoded in its behaviour now (https://github.com/Nikaple/nest-typed-config/blob/main/lib/loader/file-loader.ts#L66)

Expected behavior

Add ability to use arbitrary ENV variable when loading config files. The default value for it is NODE_ENV. But overall NODE_ENV isn't designed for specifying deployment env rather the application modes (https://stackoverflow.com/a/53368078)

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: X.Y.Z
Nest-Typed-Config version: X.Y.Z


For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Nikaple commented 9 months ago

You can do this by provide arbitary basename parameter to fileLoader, such as .env.${process.env.MY_ENV}

alexey-shakura commented 9 months ago

@Nikaple that works, thanks for quick reply!