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'd like to use env vars name directly like so, e.g.: config.SERVER_PORT without having to map it to arbitrary config object, obstructing the name which is then accessible under a different name, e.g. config.server.port.
This change would...
make it easier to found all the usages of a environment variable
make life easier without having to worry too much about the config object structure (additional layer of naming, nesting..)
prevent misusing the config object structure (it is not defined and every developer may understand it differently)
What alternatives have you considered?
Composing the config object the same way as the environment variable name, e.g.
but then I find it unnecessary, still prone to typos and I believe this could be done automatically. The only thing it needs is to keep type safety.
Alternative idea for defining the config by following Record<string, Loader>:
config={SERVER_PORT: loader.number(),}
Another idea could be to generate such config file automatically from .env.jsonc, which could nicely work with the descriptions there, but it would make it harder to select appropriate loader, and even harder with customer loaders (But I would sacrifice the customer loaders altogether, I believe such code that needs additional transformation of the config belongs in application logic, not config loader, but that's a different topic)
Additional context
No response
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem?
No.
What feature would you like to see?
I'd like to use env vars name directly like so, e.g.:
config.SERVER_PORT
without having to map it to arbitrary config object, obstructing the name which is then accessible under a different name, e.g.config.server.port
.This change would...
What alternatives have you considered?
Composing the config object the same way as the environment variable name, e.g.
but then I find it unnecessary, still prone to typos and I believe this could be done automatically. The only thing it needs is to keep type safety.
Alternative idea for defining the config by following Record<string, Loader>:
Another idea could be to generate such config file automatically from .env.jsonc, which could nicely work with the descriptions there, but it would make it harder to select appropriate loader, and even harder with customer loaders (But I would sacrifice the customer loaders altogether, I believe such code that needs additional transformation of the config belongs in application logic, not config loader, but that's a different topic)
Additional context
No response
The text was updated successfully, but these errors were encountered: