JSON Environment Variables
I would like my configuration file to reference JSON environment variables. I don’t believe Rejoice can handle this:
"plugins": { "dbModule": "$env.jsonEnvVariable" }
where jsonEnvVariable is a list of db connection details as such:
[{"options":{"name":"db1", ... }}
,{"options":{"name":"db2", ...}}]
Rejoice passes this environment variable one time into the dbModule register function as a string (as expected). I would like it to call the dbModule register function twice, once for each option object (how it behaves if the JSON is hardcoded). This would allow me to continue leveraging the simplicity of Rejoice for configuration setup rather than handling this in the dbModule.
My suggestion for a fix:
Rejoice's parseEnv function (line 110) could check if
process.env[value.slice(5)]
returns valid JSON, and if so,
JSON.parse the key value rather than keep it a string.
Something like this:
try{
manifest[key] = JSON.parse(process.env[value.slice(5)]);
}
catch(e){
manifest[key] = process.env[value.slice(5)];
}
This sounds like it could be useful. I checked with a few members to make sure this doesn't go out of scope of its intended purpose and I think this is a reasonable change. Feel free to do a PR to add this feature and add the required test(s) to ensure it is fully covered. Thanks in advance!
Closing this issue up due to lack of activity.