UNPKG

@creditkarma/dynamic-config

Version:

Dynamic Config for Node.js backed by Consul and Vault

43 lines 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SyncConfig = void 0; const utils_1 = require("./utils"); class SyncConfig { constructor(config) { this.config = config; } get(key) { const baseValue = utils_1.ConfigUtils.getConfigForKey(key, this.config); if (baseValue !== null) { return utils_1.ConfigUtils.readConfigValue(baseValue); } else { return null; } } getAll(...args) { return args .map((next) => { return this.get(next); }) .map((baseValue) => { if (baseValue !== null) { return utils_1.ConfigUtils.readConfigValue(baseValue); } else { return null; } }); } getWithDefault(key, defaultVal) { const configVal = this.get(key); if (configVal !== null) { return configVal; } else { return defaultVal; } } } exports.SyncConfig = SyncConfig; //# sourceMappingURL=SyncConfig.js.map