From 250ead165bd51c4b9812d514c724d320f526d90c Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 25 Sep 2017 09:31:26 -0700 Subject: [PATCH] generalized config variable check --- helpers/configVarCheck.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/helpers/configVarCheck.js b/helpers/configVarCheck.js index 527d5811..b4b40e51 100644 --- a/helpers/configVarCheck.js +++ b/helpers/configVarCheck.js @@ -1,17 +1,20 @@ const config = require('config'); const logger = require('winston'); +const fs = require('fs'); module.exports = function () { - let configVars = []; - configVars.push(config.get('Logging')); - configVars.push(config.get('Database')); - configVars.push(config.get('AnalyticsConfig')); - configVars.push(config.get('WalletConfig')); + // get the config file + const defaultConfigFile = JSON.parse(fs.readFileSync('./config/default.json')); - for (let i = 0; i < configVars.length; i++) { - for (let key in configVars[i]) { - if (configVars[i].hasOwnProperty(key)) { - logger.debug(`CONFIG CHECK: ${key} === ${configVars[i][key]}`); + for (let configCategoryKey in defaultConfigFile) { + if (defaultConfigFile.hasOwnProperty(configCategoryKey)) { + // get the final variables for each config category + const configVariables = config.get(configCategoryKey); + for (let configVarKey in configVariables) { + if (configVariables.hasOwnProperty(configVarKey)) { + // print each variable + logger.debug(`CONFIG CHECK: ${configCategoryKey}.${configVarKey} === ${configVariables[configVarKey]}`); + } } } }