Method for managing app settings with Node.js / Heroku env variables

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:

extend = (source, replacement)->

  for k, v of replacement

    source[k] = v

  source

module.exports =

  create: ->

    env_settings = this[process.env.NODE_ENV]

    extend this.general, env_settings

This allows me to write the following settings:

settings = require 'square-settings'

settings.general =

  domain: '0.0.0.0:3000'

settings.production =

  domain: 'www.somewhere.com'

module.exports = settings.create()

Everything in settings.general are the default settings. I can overwrite it for each environment by adding settings.environment.