Super simple project configuration
Zero configuration config module. Simply require the module and your project's config files will be loaded and merged together.
default configuration file is looked for and loaded first, followed by an
environment level config file, based on
NODE_ENV. Lastly a
local config file
is loaded. All configuration files are recursively extended into any previously
.json extentions will be loaded.
local file is the last on the list to give you the flexibility of having per
user configs, this file is generally included in your
.gitignore to provide
flexibility on the end developer. This could also be used as part of a deployment
strategy if you don't want to rely on
NODE_ENV based settings. Simply copy or
move the file you want, lets say
to ensure the correct app configuration reguardless of your environment variables.
There are plenty of other configuration modules out there, so why another one?
I wanted a config module that I didn't have to configure, with many others you
will end up including the module, telling it where your files live, and / or
providing it defaults. You might just end up with a
config.js file as a wrapper
to the module of your choosing, too much work I say! This is meant to be an
extremely simple way of configuring your app, all while having a
in mind, which can be very useful when a team is working on the same project.
var config = require'configs'
Config files will be be loaded with the following pattern, pathing is relative
to the project root directory. The project root directory is found by following
module.parent recursively until there either is no more parents or a
package.json file is found.
"debug": false"database":"host": "localhost""port": 6379"user": "paul"
"debug": true"database":"port": 11212
"debug": true"database":"host": "localhost""port": 11212"user": "paul"
If only a single configuration file is found, the module will check for a property
matching the current
NODE_ENV and extend it into the base config.
"something": true"sea":"lab": 2021"production":"something": false"hey": "there"
"something": false"hey": "there""sea":"lab": 2021"production":"something": false"hey": "there"
debug property is found after all files have been loaded, the module
will output the file paths of everything that was loaded.
package.json is found within the root directory, the
will be added to the config. The module will also check for a
that can be used to specify the directory in which the files are located. Defaults
npm install configs
(The MIT License)
Copyright (c) 2011-2012 Beau Sorensen firstname.lastname@example.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.