Skip to content

Instantly share code, notes, and snippets.

@leobrines
Created May 3, 2019 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leobrines/069288b58df012b180bdb4ea8c037246 to your computer and use it in GitHub Desktop.
Save leobrines/069288b58df012b180bdb4ea8c037246 to your computer and use it in GitHub Desktop.
Enviroment configuration for NodeJS - "Twelve-Factor App" | https://12factor.net/config
const enviroment = {};
Object.assign(enviroment, process.env);
for (let [key, value] of Object.entries(enviroment)) {
switch (value) {
case "true":
enviroment[key] = true;
break;
case "false":
enviroment[key] = false;
break;
default:
if (Number(value))
enviroment[key] = Number(value);
}
}
module.exports = enviroment;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment