Skip to content

Instantly share code, notes, and snippets.

@aredridel
Created October 21, 2012 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aredridel/3927254 to your computer and use it in GitHub Desktop.
Save aredridel/3927254 to your computer and use it in GitHub Desktop.
Example of configuration injection in node.js
{
"value": "config value here"
}
var submodule = require('submodule').config(require('config.json'));
submodule.frobnicate();
var configuration = {};
module.exports = {
config: function(config) {
configuration = config;
return module.exports;
},
frobnicate: function() {
console.log("Config value is ", configuration.value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment