diff --git a/keyserver/src/utils/import-json.js b/keyserver/src/utils/import-json.js index fb2318a45..781f9a694 100644 --- a/keyserver/src/utils/import-json.js +++ b/keyserver/src/utils/import-json.js @@ -1,26 +1,34 @@ // @flow const cachedJSON = new Map(); async function importJSON(path: string): Promise { const cached = cachedJSON.get(path); if (cached !== undefined) { return cached; } const json = await getJSON(path); if (!cachedJSON.has(path)) { cachedJSON.set(path, json); } return cachedJSON.get(path); } async function getJSON(path: string): Promise { + const fromEnv = process.env[`COMM_JSONCONFIG_${path}`]; + if (fromEnv) { + try { + return JSON.parse(fromEnv); + } catch (e) { + console.log(`failed to parse JSON from env for ${path}`, e); + } + } try { // $FlowFixMe const importedJSON = await import(`../../${path}`); return importedJSON.default; } catch { return null; } } export { importJSON };