services/config.js
function loadFromIndividualConfigFile(key) {
    key = _.replace(key, /\/|\\/g, ''); //forward and backslashes are unsafe when resolving filenames

    if (individualKeyCache[key]) {
        return individualKeyCache[key];
    } else {
        var toLoad = path.resolve(global.__appDir, 'config/' + key + '.json');

        var content = '{}';
        try {
            content = fs.readFileSync(toLoad);
        } catch (err) {
            //file must not exists
        }

        var json = {};
        try {
            json = JSON.parse(stripJsonComments(content.toString()));
        } catch (err) {
            console.warn('Error parsing JSON for %s', toLoad);
        }

        security.decryptObject(json, function (str) {
            //Decryption function
            return security.decrypt(str, process.env.decryptionKey);
        });
        individualKeyCache[key] = json;

        return individualKeyCache[key];
    }
}
function loadFromIndividualConfigFile(key) {
    key = _.replace(key, /\/|\\/g, ''); //forward and backslashes are unsafe when resolving filenames

    if (individualKeyCache[key]) {
        return individualKeyCache[key];
    } else {
        var toLoad = path.resolve(global.__appDir, 'config/' + key + '.json');

        var content = '{}';
        try {
            content = fs.readFileSync(toLoad);
        } catch (err) {
            //file must not exists
        }

        var json = {};
        try {
            json = JSON.parse(stripJsonComments(content.toString()));
        } catch (err) {
            console.warn('Error parsing JSON for %s', toLoad);
        }

        security.decryptObject(json, function (str) {
            //Decryption function
            return security.decrypt(str, process.env.decryptionKey);
        });
        individualKeyCache[key] = json;

        return individualKeyCache[key];
    }
}
function loadFromIndividualConfigFile ( key ) { key = _ . replace ( key , / \/|\\ / g , '' ) ; //forward and backslashes are unsafe when resolving filenames if ( individualKeyCache [ key ] ) { return individualKeyCache [ key ] ; } else { var toLoad = path . resolve ( global . __appDir , 'config/' + key + '.json' ) ; var content = '{}' ; try { content = fs . readFileSync ( toLoad ) ; } catch ( err ) { //file must not exists } var json = { } ; try { json = JSON . parse ( stripJsonComments ( content . toString ( ) ) ) ; } catch ( err ) { console . warn ( 'Error parsing JSON for %s' , toLoad ) ; } security . decryptObject ( json , function ( str ) { //Decryption function return security . decrypt ( str , process . env . decryptionKey ) ; } ) ; individualKeyCache [ key ] = json ; return individualKeyCache [ key ] ; } }
For every requested config key, check if there's a json file by that name in the config dir. If there is, load the contents and return it so that it can be merged in.
For every requested config key check if there s a json file by that name in the config dir . If there is load the contents and return it so that it can be merged in .