Skip to content
environment variables made easy
JavaScript
Find file
Pull request Compare This branch is 2 commits ahead, 7 commits behind markbao:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
LICENSE
README.md
example.js
main.js
package.json

README.md

envious: environment variables made easy, fun, and finally profitable

envious makes it absurdly easy for you to configure your environment, so you can have a central place to define credentials and whatnot.

install

npm install envious

textbook example

put this in your pipe

var envious = require('envious');

envious.development = 
{
  "mongodb_hostname": "dev.local",
  "site_url": "http://127.0.0.1/",
}

envious.production = 
{
  "mongodb_hostname": "masterdb.sterlingcooper.com",
  "site_url": "http://zombo.com/",
}

envious.default_env = "development";

var env = envious.apply();

console.log(env.site_url);

and smoke it

NODE_ENV=production node app.js

options

strict: strict environment checking

var env = envious.apply({strict: true});

when strict is on, it will throw an error if the environment does not exist. normally, it would simply fall back to the default.

tests

you have to run the tests a certain way.

  • normal.js: tests normal function. NODE_ENV=production node normal.js
  • default.js: tests the default environment feature. node default.js
  • strict.js: tests strict mode. NODE_ENV=bogus node strict.js
Something went wrong with that request. Please try again.