From 1c39a5194486dd23af063678bc855d8c14ec4d3d Mon Sep 17 00:00:00 2001 From: Evgeny Aleksandrov Date: Thu, 1 Mar 2018 12:55:28 +0300 Subject: [PATCH] Update config setup with overrides for Docker --- docker.config.json | 18 ------------------ libs/config.js | 20 +++++++++++--------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/docker.config.json b/docker.config.json index b499495..661e0f1 100644 --- a/docker.config.json +++ b/docker.config.json @@ -1,23 +1,5 @@ { - "port": 1337, - "security": { - "tokenLife" : 3600 - }, "mongoose": { "uri": "mongodb://mongo/apiDB" - }, - "default": { - "api": { - "version" : "v1" - }, - "user": { - "username": "myapi", - "password": "abc1234" - }, - "client": { - "name": "Android API v1", - "clientId": "android", - "clientSecret": "SomeRandomCharsAndNumbers" - } } } diff --git a/libs/config.js b/libs/config.js index 1527b65..32a3a54 100644 --- a/libs/config.js +++ b/libs/config.js @@ -1,13 +1,15 @@ var nconf = require('nconf'); -var config = (process.env.ENV_IN === 'docker') ? - '/docker.config.json' : - '/config.json'; +nconf.argv().env(); -nconf.argv() - .env() - .file({ - file: process.cwd() + config - }); +if (process.env.ENV_IN === 'docker') { + nconf.file('docker', { + file: process.cwd() + '/docker.config.json' + }); +} -module.exports = nconf; \ No newline at end of file +nconf.file('defaults', { + file: process.cwd() + '/config.json' +}); + +module.exports = nconf;