Skip to content

Instantly share code, notes, and snippets.

@camshaft
Last active December 14, 2015 16:58
Show Gist options
  • Save camshaft/5118648 to your computer and use it in GitHub Desktop.
Save camshaft/5118648 to your computer and use it in GitHub Desktop.
DB_URL=mongo://...
/**
* Module deps
*/
var config = require("config");
// Get the DB
var DB_URL = config("DB_URL", "You need to set DB_URL for the mongo instance");
// Throws an exception
var REDIS_URL = config("REDIS_URL", "You need to set REDIS_URL for the redis instance");
/**
* Get the config
*/
var defaults = {};
exports = module.exports = function(name, message) {
if(process.env[name]) return process.env[name];
if(defaults[name]) return defaults[name];
throw new Error(message);
}
exports.default = function(key, value) {
defaults[key] = value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment