Environment object mapping module
- Source:
(require("src/util/env-config"))(config, environment, mappings) → {Object}
Use mapping to overwrite config fields with corresponding environment object fields.
If given, call a parsing function.
Each mapping must contains the environment variable name, an path to the config object target
and an optional parsing function.
Parameters:
Name | Type | Description |
---|---|---|
config |
Object | Config object |
environment |
Object | Environment object (usually process.env) |
mappings |
Array | Environment to object mappings |
- Source:
Returns:
updated config
- Type
- Object
Example
envConfig(conf, env, [
['FOO', 'FOO'],
['OBJ_PATH', 'OBJ.PATH', envParser.int(0)]
])