allow database.js config

This commit is contained in:
Sascha Gehlich 2012-12-17 10:25:27 +01:00
parent 9fed918db8
commit 252a067df7
1 changed files with 8 additions and 1 deletions

View File

@ -27,7 +27,14 @@ module.exports = function init(root) {
var confFile = (root || app.root) + '/config/database'; var confFile = (root || app.root) + '/config/database';
var config = {}; var config = {};
if (existsSync(confFile + '.json')) { if (existsSync(confFile + '.js')) {
try {
config = require(confFile + '.js');
} catch (e) {
console.log('Could not load config/database.js');
throw e;
}
} else if (existsSync(confFile + '.json')) {
try { try {
config = JSON.parse(fs.readFileSync(confFile + '.json', 'utf-8'))[app.set('env')]; config = JSON.parse(fs.readFileSync(confFile + '.json', 'utf-8'))[app.set('env')];
} catch (e) { } catch (e) {