Skip to content

Instantly share code, notes, and snippets.

@lackac
Created October 25, 2012 14:31
Show Gist options
  • Save lackac/3952872 to your computer and use it in GitHub Desktop.
Save lackac/3952872 to your computer and use it in GitHub Desktop.
Simple configuration which is overridable through env vars
# Find the appropriate setting for the provided key
module.exports = config = (key) ->
# return setting from environment variable
if env_value = process.env[key.toUpperCase()]
try
return JSON.parse(env_value)
catch err
if err instanceof SyntaxError
return env_value
else
throw err
# return default value
config[key]
config.mongo_url = "mongodb://localhost/bibliaolvaso"
config.session_secret = "YOUR SECRET HERE"
config.cookie_max_age = 365 * 24 * 3600000
config.facebook_app_id = 'FACEBOOK KEY'
config.facebook_secret = 'FACEBOOK SECRET'
config.default_user_values =
last_chapter: '/ujforditas/1moz/1'
ui: {format: 'continuous', text_size: 'medium'}
# Allow overriding defaults with environment specific settings
try
env_settings = require "./#{process.env.NODE_ENV ? 'development'}"
for key, value of env_settings
config[key] = value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment