Baphomet is the dedicated bot for nulloctet matrix
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

28 lines
830 B

let fs = require('fs');
let { logger } = require('./logging');
let loadedConfigs = new Map();
function sanitizeConfig(config, fields=[]) {
let clonedConfig = { ...config };
fields.forEach((field) => {
clonedConfig[field] = '******'
})
return clonedConfig;
}
function getConfig(configFile, sanitizedFields=[]) {
if (!loadedConfigs.has(configFile)) {
logger.info("Reading config: %s", configFile);
let rawConfigData = fs.readFileSync(configFile);
let config = JSON.parse(rawConfigData);
logger.info("Loaded config: %s", configFile);
logger.debug("%o", sanitizeConfig(config, sanitizedFields));
loadedConfigs.set(configFile, config);
return config;
} else {
return loadedConfigs.get(configFile);
}
}
exports.getConfig = getConfig