Created
October 21, 2012 15:20
-
-
Save aredridel/3927254 to your computer and use it in GitHub Desktop.
Example of configuration injection in node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"value": "config value here" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var submodule = require('submodule').config(require('config.json')); | |
submodule.frobnicate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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