env-get
v1.0.8
Published
simple tool to wrap fetching of env variables in node.js
Downloads
3
Maintainers
Readme
env-get
Simple utility to get environment variables with an optional default.
Throws an error if the variable is not found and no default is supplied.
This utility was designed to support twelve-factor applications and the strict separation of code and config.
Usage:
const env = require('env-get');
// PORT not set
const port = env.get('PORT', 4000);
console.log(port); // 4000
// TOKEN not set
const token = env.get('TOKEN'); // throws Error
// HOSTNAME set
const hostname = env.get('HOSTNAME');
console.log(hostname); // blaing.io