-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URLSearchParams to split process.env variables #1730
Comments
Having a config/env module for the process.env variables may help with transofrmations, defaults, and documentation as well. |
This kind of thing is already built into dotenv. |
Also this needs more clarification. Are we talking about (as an example) a single string that has all the different possible DB_* entries? |
https://github.com/dotenvx/dotenvx I think the route of a single entry for module doesn't quite make sense to be as it will quite hard to read when configuring/debugging. I think we should possibly make use of a package like the new dotenvx which we can use to combine multiple .env files which we can use to split up different module .env variables. As for getting all the different variables that we would need for a module we should just be able to provide a prefix and get them from the process. const getEnvsByPrefix = (prefix) => {
return Object.keys(process.env)
.filter(key => key.startsWith(prefix))
.reduce((obj, key) => ({
...obj,
[key]: process.env[key]
}), {});
}; Something like this would be ideal where we could provide |
more complex functions on variables can be implemented in the configuration module. |
Where multiple process.env variables are required to support a single module it would be advantageous to provide a single environment variable which can split with URLSearchParams.
This could be applied for SAML2, Mailer [TRANSPORT], dbs, and possibly more.
The text was updated successfully, but these errors were encountered: