Add deep properties getter utility function to config.

cfg._("a.deep.property") returns the value of
cfg.a.deep.property if it exists. If the property
or any of its parents do not exist, returns undefined.
This commit is contained in:
D. Berge
2020-08-31 13:07:27 +02:00
parent 5363ce8bab
commit 433daca9ef

View File

@@ -69,4 +69,6 @@ if (process.env.PGDATABASE) {
delete config.db;
}
config._ = (k) => k.split(".").reduce((a, b) => typeof a != "undefined" ? a[b] : a, config);
module.exports = Object.freeze(config);