Skip to content

Commit

Permalink
Uses confilter for config
Browse files Browse the repository at this point in the history
  • Loading branch information
rjz committed Aug 16, 2014
1 parent 2749bd0 commit c88c038
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app.js
Expand Up @@ -2,7 +2,7 @@ var _ = require('lodash'),
express = require('express'),
errors = require('http-error-factories');

var config = require('./config.json');
var config = require('./config');

var middleware,
port = config.port,
Expand Down
4 changes: 0 additions & 4 deletions config.json

This file was deleted.

4 changes: 4 additions & 0 deletions config/config.json
@@ -0,0 +1,4 @@
{

}

4 changes: 4 additions & 0 deletions config/config.test.json
@@ -0,0 +1,4 @@
{

}

22 changes: 22 additions & 0 deletions config/index.js
@@ -0,0 +1,22 @@
var confilter = require('confilter'),
path = require('path');

module.exports = confilter([

// Paths to load config files from
confilter.loadJSON([
path.resolve(__dirname, 'config.' + process.env.NODE_ENV + '.json'),
path.resolve(__dirname, 'config.json')
]),

// Any defaults to fill in when missing from the config
confilter.defaults({
port: 3200
}, true),

// Any defaults to fill in when missing from the config
confilter.required([
// List required keys here
])
]);

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"start": "WORKERS=2 node index | ./node_modules/bunyan/bin/bunyan",
"test": "jshint . && NODE_ENV=test ./node_modules/mocha/bin/mocha",
"test": "node_modules/jshint/bin/jshint && ./node_modules/mocha/bin/mocha",
"cover": "NODE_ENV=test istanbul cover ./node_modules/mocha/bin/_mocha && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"config": "node tools/config"
},
Expand All @@ -21,6 +21,7 @@
},
"dependencies": {
"bunyan": "^0.23.1",
"confilter": "0.0.1",
"express": "^4.6.1",
"http-error-factories": "0.0.1",
"lodash": "^2.4.1"
Expand Down

0 comments on commit c88c038

Please sign in to comment.