Methods
generate(obj) → {object}
Generates an object suitable for use with config's config/custom-environment-variables.json, skipping any functions encountered in the given object.
Example:
const fs = require('fs');
const config = require('config');
const cev = require('config-custom-environment-variables-generator');
fs.writeFileSync('config/custom-environment-variables.json', JSON.stringify(cev.generate(config, { prefix: 'MYAPP' }), null, 2)));
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
obj |
object | An object, most likely the one returned by |
||
opts.prefix |
string |
<optional> |
'NODE_APP' | Prefix to use on environment variables. Use |
opts.noPrefix |
boolean |
<optional> |
false | Overrides use of any prefix (see exported |
opts.separator |
separator |
<optional> |
'_' | The word separator in environment variables (see exported |
opts.casing |
'upper' | 'lower' | undefined |
<optional> |
'upper' | The case to use. |
opts.empties |
boolean |
<optional> |
false | If |
opts.formats |
object |
<optional> |
{} | If given, must be an object that specifies the __format value for the corresponding key of the first argument, |
- Source:
Returns:
An object containing the generated environment variables for each key in the input object.
- Type
- object
generate(obj) → {object}
Generates an object suitable for use with config's config/custom-environment-variables.json, skipping any functions encountered in the given object.
Example:
const fs = require('fs');
const config = require('config');
const cev = require('config-custom-environment-variables-generator');
fs.writeFileSync('config/custom-environment-variables.json', JSON.stringify(cev.generate(config, { prefix: 'MYAPP' }), null, 2)));
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
obj |
object | An object, most likely the one returned by |
||
opts.prefix |
string |
<optional> |
'NODE_APP' | Prefix to use on environment variables. Use |
opts.noPrefix |
boolean |
<optional> |
false | Overrides use of any prefix (see exported |
opts.separator |
separator |
<optional> |
'_' | The word separator in environment variables (see exported |
opts.casing |
'upper' | 'lower' | undefined |
<optional> |
'upper' | The case to use. |
opts.empties |
boolean |
<optional> |
false | If |
opts.formats |
object |
<optional> |
{} | If given, must be an object that specifies the __format value for the corresponding key of the first argument, |
- Source:
Returns:
An object containing the generated environment variables for each key in the input object.
- Type
- object