Skip to content
/ dirconf Public

Node.js module that loads configuration files from a directory

License

Notifications You must be signed in to change notification settings

ewngs/dirconf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Load configuration files from a directory

Build Status

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 --save

Usage

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.

About

Node.js module that loads configuration files from a directory

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published