Skip to content

keithamus/zero-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zero-env

This is a zero configuration script which takes environment variables and turns them into an object. This allows for simple environment based configuration with virtually no effort.

Install

npm install --save zero-env

Usage

Simply require the file, and it will provide you with a configuration object:

export NODE_ENV='production'
export SERVER_PORT='8080'
export SERVER_ASSETS_FOLDER='public/'
export SERVER_ASSETS_URL='/'
export DEBUG_STATIC='true'
export some_otherValue='yes'
node index.js
var config = require('zero-env');
var assert = require('assert');
// all caps values are converted to lowercase
assert(config.node.env === 'production');
assert(config.server.port === 8080); // Numeric strings are converted to numbers
assert(config.assets.folder === 'public/');
assert(config.assets.url === '/');
assert(config.debug.static === true); // Boolean strings are converted to booleans
assert(config.some.otherValue === 'yes'); // camelCase vars are respected

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published