From aa369504a79a468c4edbd0829f9b1992356b54d8 Mon Sep 17 00:00:00 2001 From: Lloyd Hilaiel <lloyd@hilaiel.com> Date: Wed, 17 Aug 2011 16:24:28 +0300 Subject: [PATCH] DRY in specification of different deployment environments --- libs/configuration.js | 72 ++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/libs/configuration.js b/libs/configuration.js index 5f45d3b0a..333d9598b 100644 --- a/libs/configuration.js +++ b/libs/configuration.js @@ -56,48 +56,44 @@ exports.get = function(val) { return g_config[val]; } -var defaultHostedDatabaseConfig = { - driver: "mysql", - user: 'browserid' -}; +// *** the various deployment configurations *** +const g_configs = { }; -// various deployment configurations -const g_configs = { - production: { - hostname: 'browserid.org', - port: '443', - scheme: 'https', - use_minified_resources: true, - log_path: '/home/browserid/var/', - database: defaultHostedDatabaseConfig - }, - development: { - hostname: 'dev.diresworb.org', - port: '443', - scheme: 'https', - use_minified_resources: true, - log_path: '/home/browserid/var/', - database: defaultHostedDatabaseConfig - }, - beta: { - hostname: 'diresworb.org', - port: '443', - scheme: 'https', - use_minified_resources: true, - log_path: '/home/browserid/var/', - database: defaultHostedDatabaseConfig - }, - local: { - hostname: '127.0.0.1', - port: '10002', - scheme: 'http', - email_to_console: true, // don't send email, just dump verification URLs to console. - use_minified_resources: false, - log_path: path.join(__dirname, "..", "var", "logs"), - database: { driver: "json" } +// production is the configuration that runs on our +// public service (browserid.org) +g_configs.production = { + hostname: 'browserid.org', + port: '443', + scheme: 'https', + use_minified_resources: true, + log_path: '/home/browserid/var/', + database: { + driver: "mysql", + user: 'browserid' } }; +// beta (diresworb.org) the only difference from production +// is the hostname +g_configs.beta = JSON.parse(JSON.stringify(g_configs.production)); +g_configs.beta.hostname = 'diresworb.org'; + +// development (dev.diresworb.org) the only difference from production +// is, again, the hostname +g_configs.dev = JSON.parse(JSON.stringify(g_configs.production)); +g_configs.dev.hostname = 'dev.diresworb.org'; + +// local development configuration +g_configs.local = { + hostname: '127.0.0.1', + port: '10002', + scheme: 'http', + email_to_console: true, // don't send email, just dump verification URLs to console. + use_minified_resources: false, + log_path: path.join(__dirname, "..", "var", "logs"), + database: { driver: "json" } +}; + // default deployment is local if (undefined === process.env['NODE_ENV']) { process.env['NODE_ENV'] = 'local'; -- GitLab