Created
December 27, 2018 22:09
-
-
Save tarusharora/ce55f37b7f06ff7991f7aecfaa4c0efb to your computer and use it in GitHub Desktop.
Configuration Adaptor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nconf = require('nconf'); | |
const _ = require('lodash'); | |
const loadSettings = ({ appSettingsPath }) => new Promise((resolve, reject) => { | |
try { | |
if (_.isEmpty(appSettingsPath)) { | |
throw new Error('Configuration settings path is required.'); | |
} | |
nconf.file({ | |
file: appSettingsPath, | |
// Setting the separator as dot for nested objects | |
logicalSeparator: '.', | |
}); | |
resolve(); | |
} catch (err) { | |
reject(err); | |
} | |
}); | |
module.exports.loadSettings = loadSettings; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment