@coast/dynamic-config
Advanced tools
Comparing version 1.4.6 to 1.4.7
@@ -13,3 +13,2 @@ import { SSM } from 'aws-sdk'; | ||
* Loads config values in priority order | ||
* | ||
* @returns {Promise<Record<string, unknown>>} The validated configuration map. | ||
@@ -16,0 +15,0 @@ * Values will be coerced to their primitive types if appliable |
@@ -22,3 +22,2 @@ "use strict"; | ||
* Loads config values in priority order | ||
* | ||
* @returns {Promise<Record<string, unknown>>} The validated configuration map. | ||
@@ -28,25 +27,15 @@ * Values will be coerced to their primitive types if appliable | ||
async loadConfig() { | ||
console.log('loadConfig called', new Date()); | ||
const allKeys = this.getAllKeys(); | ||
console.log('allKeys loaded', new Date()); | ||
const entries = {}; | ||
this.loadFromSource(allKeys, process.env, entries); | ||
console.log('process.env loaded', new Date()); | ||
let dotEnvParse = {}; | ||
console.log('looking up dotenv?', this.options.envFilePath !== undefined); | ||
if (this.options.envFilePath !== undefined && fs_1.default.existsSync(this.options.envFilePath)) { | ||
console.log('attempting dotenv', new Date()); | ||
dotEnvParse = dotenv_1.default.parse(fs_1.default.readFileSync(this.options.envFilePath)); | ||
this.loadFromSource(this.getAllUnsetKeys(allKeys, entries), dotEnvParse, entries); | ||
console.log('dotenv loaded', new Date()); | ||
} | ||
const missingEntries = this.getAllUnsetKeys(allKeys, entries); | ||
console.log({ missing: missingEntries.length > 0, skipSSM: this.options.skipSsm }); | ||
if (missingEntries.length > 0 && !this.options.skipSsm) { | ||
console.log('attempting ssm', new Date()); | ||
await this.loadFromSsm(missingEntries, dotEnvParse, entries); | ||
console.log('ssm loaded', new Date()); | ||
} | ||
this.configuration = joi_1.default.attempt(entries, this.options.schema, { allowUnknown: this.options.allowUnknownVariables }); | ||
console.log('configuration validated', new Date()); | ||
return this.configuration; | ||
@@ -53,0 +42,0 @@ } |
{ | ||
"name": "@coast/dynamic-config", | ||
"version": "1.4.6", | ||
"version": "1.4.7", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
12169
156