let rethinkdbConfig = {
  host: process.env.RETHINKDB_HOST || 'localhost',
  port: process.env.RETHINKDB_PORT || 28015,
  db:   'quill_lessons'
}

if (process.env.RETHINKDB_USER) {
  rethinkdbConfig['user'] = process.env.RETHINKDB_USER
}

if (process.env.RETHINKDB_PASSWORD) {
  rethinkdbConfig['password'] = process.env.RETHINKDB_PASSWORD
}

export default rethinkdbConfig

const rethinkdbConfig = (() => {
  let config = {
    host: process.env.RETHINKDB_HOST || 'localhost',
    port: process.env.RETHINKDB_PORT || 28015,
    db:   'quill_lessons'
  }

  if (process.env.RETHINKDB_USER) {
    config['user'] = process.env.RETHINKDB_USER
  }

  if (process.env.RETHINKDB_PASSWORD) {
    config['password'] = process.env.RETHINKDB_PASSWORD
  }

  return config
})()

export default rethinkdbConfig

Use module pattern because its javascript