Skip to content

Instantly share code, notes, and snippets.

@tj
Last active December 27, 2015 14:49
Show Gist options
  • Save tj/7343489 to your computer and use it in GitHub Desktop.
Save tj/7343489 to your computer and use it in GitHub Desktop.
/**
* Module dependencies.
*/
var pkg = require('../package');
var env = process.env.NODE_ENV || 'development';
/**
* Return setting `name`.
*
* @param {String} name
* @return {Mixed}
* @api public
*/
module.exports = function(name){
if (null == pkg[env]) throw new Error('invalid configuration environment "' + env + '"');
if (null == pkg[env][name]) throw new Error('invalid configuration key "' + name + '"');
return pkg[env][name];
};
@tj
Copy link
Author

tj commented Nov 7, 2013

assume production would be safer as far as precedence goes, I've found throwing extremely helpful, little typos in config etc go undetected, it would have to be a pretty massive fail to have that throw in production, so unless you don't write tests or use your app at all it's fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment