Optionaloptions: { Optionalseparator?: stringKey separator, default .
OptionaltransformKey transform function, e.g. camelCase or pascalCase
OptionaltransformValue transform function, by default JSON.parse is used.
// ENV: config__host=0.0.0.0 config__port=3000
convertToNested(process.env, { separator: '__' })
// {config: { host: '0.0.0.0', port: 3000 } }
// ENV: CONFIG__PRIVATE_KEY="my key"
// ENV: CONFIG__PUBLIC_KEY="my key"
// ENV: CONFIG__ALLOWED_IPS='["127.0.0.1", "localhost"]'
convertToNested(process.env, {
separator: '__',
transformKey: camelCase
}).config
// { privateKey: 'my key', publicKey: 'my key', allowedIps: ['127.0.0.1', 'localhost'] }
Parse one level object to nested structure based on key separator