Currently, I have several “environments” which are loaded using NODE_ENV
(I’m using RailwayJS / express)
development.js
app.set(‘mongodb_connection_string’, ‘mongodb://localhost/’) // example
production.js:
app.set(‘mongodb_connection_string’, process.env.MONGOLAB_URI)
So, in production, we’re using the MONGOLAB_URI variable set within heroku.
Just wondering if there’s a better way of managing these, without having to double up, and set app.set(‘mongodb_connection_string’) ??
I use this really tiny module for that. It’s written in coffee-script if you can’t read it let me know and I’ll translate it:
This allows me to write the following settings:
Everything in settings.general are the default settings. I can overwrite it for each environment by adding settings.environment.