Skip to content

Instantly share code, notes, and snippets.

@desmondmorris
Last active December 23, 2015 22:25
Show Gist options
  • Save desmondmorris/8accf4a5920b6ba4d759 to your computer and use it in GitHub Desktop.
Save desmondmorris/8accf4a5920b6ba4d759 to your computer and use it in GitHub Desktop.
An environment aware config module for node.js
/**
* An environment aware configuration module.
*
* @module config/config
*/
'use strict';
// Module dependencies
var extend = require('util')._extend;
var config = {
// All enviornments inherit from here.
"default": {
environment: process.env.NODE_ENV || "development",
port: process.env.PORT || 3000,
mongo: {
uri: process.env.MONGO_URI || "mongodb://127.0.0.1:27017"
},
redis: {
uri: process.env.REDIS_URI || "redis://127.0.0.1:6379"
}
},
"development": {},
"test": {},
"production": {}
};
module.exports = extend(
config.default,
config[config.default.environemnt] || {}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment