You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been debating for a while if the method of storing application configurations in an injectable class is the best approach. Since the AsyncProvider was added to nestjs it would be possible to await the loading of the config module to create providers for each file found from the glob.
The reason
This method would make the config providers easier to import into the constructors of injectables and would clear up implementation issues and the need for injecting the entire configuration class #30, #12.
Possible drawback
However it does mean that some functionality could be lost. Specifically the ConfigService would be rendered redundant unless we're able to inject all config providers as one provider into the ConfigService class.
If you like the idea give this comment a ❤️. If you don't, add a 👎.
TLDR;
Remove ConfigService injection and instead create a provider for each config file
The idea
I've been debating for a while if the method of storing application configurations in an injectable class is the best approach. Since the AsyncProvider was added to nestjs it would be possible to await the loading of the config module to create providers for each file found from the glob.
The reason
This method would make the config providers easier to import into the constructors of injectables and would clear up implementation issues and the need for injecting the entire configuration class #30, #12.
Possible drawback
However it does mean that some functionality could be lost. Specifically the ConfigService would be rendered redundant unless we're able to inject all config providers as one provider into the ConfigService class.
If you like the idea give this comment a ❤️. If you don't, add a 👎.
TLDR;
Remove ConfigService injection and instead create a provider for each config file
ConfigModule async provider build
Further possibilities
Types
Using types in the config could be very beneficial for validation and obviously typing in the project.
configs/app.config.ts
or
Without types
This could then be injected with
Or selected with
ConfigService.get('name_of_config.port')
.The text was updated successfully, but these errors were encountered: