Skip to content

Instantly share code, notes, and snippets.

@tarusharora
Created December 27, 2018 22:09
Show Gist options
  • Save tarusharora/ce55f37b7f06ff7991f7aecfaa4c0efb to your computer and use it in GitHub Desktop.
Save tarusharora/ce55f37b7f06ff7991f7aecfaa4c0efb to your computer and use it in GitHub Desktop.
Configuration Adaptor
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