0.1.4 • Published 9 years ago
dirconf v0.1.4
Load configuration files from a directory
This simple module loads all .js files from a given directory, merges the exported objects and returns the result. This is handy if you want to store your configuration parameters in separate files.
Installation
npm install dirconf --saveUsage
Assume you have a configs directory, with the following files in it:
mongodb.js
module.exports = {
mongodb: {
host: "localhost",
port: "31881"
}
};mailer.js
module.exports = {
mailer: {
method: "SMTP",
relayHost: "10.10.0.143",
port: "587"
}
};Then you can load the merged configutation object with:
var conf = require('dirconf')('./configs');In this example conf will contain the merged objects:
{
mongodb: {
host: "localhost",
port: "31881"
},
mailer: {
method: "SMTP",
relayHost: "10.10.0.143",
port: "587"
}
}License
MIT. See the LICENSE file for details.