env-get

1.0.8 • Public • Published

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.

Read more about it here.

NPM Version NPM Monthly Test Status Coverage Status

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

Package Sidebar

Install

npm i env-get

Weekly Downloads

3

Version

1.0.8

License

ISC

Last publish

Collaborators

  • billylaing