I'm using a node package called 'db-migrate' and it uses a database.json file as a databases configuration. The problem is we are starting to use Docker and I want to set the values as environment variables with fallback - for example:
{
...
"host": process.env.DBHOST || 'localhost',
...
}
But how can I do it with a static json file? I would like to use something similar to erb file with the dynamic abilities of template generation.
According to my understanding, better idea is to create a global config file like
config.js, and put your configurations likeAfter doing this, you can easily access this file wherever you want. For e.g. if you want to access these configurations in
app.jsfile, then simply include it by adding a line inapp.jsfileThis will make the values available under
confignamespace and the values can be accessed as :Hope the answer tells what you wanted.. If your intention is something else then please comment..