From 9a40eb623c6537296679aaf561650c6ba43cbaed Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Mon, 3 Mar 2014 08:21:15 -0800 Subject: [PATCH] Added translation by @rdxiang of server_config.js to server_config.coffee --- server_config.coffee | 49 +++++++++++++++++++++++++++++++++++++++++ server_config.js | 52 -------------------------------------------- 2 files changed, 49 insertions(+), 52 deletions(-) create mode 100644 server_config.coffee delete mode 100644 server_config.js diff --git a/server_config.coffee b/server_config.coffee new file mode 100644 index 000000000..b13bead19 --- /dev/null +++ b/server_config.coffee @@ -0,0 +1,49 @@ +config = {} + +config.unittest = process.argv.indexOf("--unittest") > -1 + +config.port = process.env.COCO_PORT or process.env.COCO_NODE_PORT or 3000 +config.ssl_port = process.env.COCO_SSL_PORT or process.env.COCO_SSL_NODE_PORT or 3443 + +config.mongo = + port: process.env.COCO_MONGO_PORT or 27017 + host: process.env.COCO_MONGO_HOST or "localhost" + db: process.env.COCO_MONGO_DATABASE_NAME or "coco" + mongoose_replica_string: process.env.COCO_MONGO_MONGOOSE_REPLICA_STRING or "" + +if config.unittest + config.port += 1 + config.ssl_port += 1 + config.mongo.host = "localhost" +else + config.mongo.username = process.env.COCO_MONGO_USERNAME or "" + config.mongo.password = process.env.COCO_MONGO_PASSWORD or "" + +config.mail = + service: process.env.COCO_MAIL_SERVICE_NAME or "Zoho" + username: process.env.COCO_MAIL_SERVICE_USERNAME or "" + password: process.env.COCO_MAIL_SERVICE_PASSWORD or "" + mailchimpAPIKey: process.env.COCO_MAILCHIMP_API_KEY or "" + mailchimpWebhook: process.env.COCO_MAILCHIMP_WEBHOOK or "/mail/webhook" + sendwithusAPIKey: process.env.COCO_SENDWITHUS_API_KEY or "" + +config.queue = + accessKeyId: process.env.COCO_AWS_ACCESS_KEY_ID or "" + secretAccessKey: process.env.COCO_AWS_SECRET_ACCESS_KEY or "" + region: "us-east-1" + simulationQueueName: "simulationQueue" + +config.mongoQueue = + queueDatabaseName: "coco_queue" + +config.salt = process.env.COCO_SALT or "pepper" +config.cookie_secret = process.env.COCO_COOKIE_SECRET or "chips ahoy" + +config.isProduction = config.mongo.host isnt "localhost" + +if not config.unittest and not config.isProduction + # change artificially slow down non-static requests for testing + config.slow_down = false + + +module.exports = config diff --git a/server_config.js b/server_config.js deleted file mode 100644 index 880fcfd78..000000000 --- a/server_config.js +++ /dev/null @@ -1,52 +0,0 @@ -var config = {}; - -config.unittest = process.argv.indexOf('--unittest') > -1; - -config.port = process.env.COCO_PORT || process.env.COCO_NODE_PORT || 3000; -config.ssl_port = - process.env.COCO_SSL_PORT || process.env.COCO_SSL_NODE_PORT || 3443; - -config.mongo = {}; -config.mongo.port = process.env.COCO_MONGO_PORT || 27017; -config.mongo.host = process.env.COCO_MONGO_HOST || 'localhost'; -config.mongo.db = process.env.COCO_MONGO_DATABASE_NAME || 'coco'; -config.mongo.mongoose_replica_string = process.env.COCO_MONGO_MONGOOSE_REPLICA_STRING || ''; - -if(config.unittest) { - config.port += 1; - config.ssl_port += 1; - config.mongo.host = 'localhost'; -} - -else { - config.mongo.username = process.env.COCO_MONGO_USERNAME || ''; - config.mongo.password = process.env.COCO_MONGO_PASSWORD || ''; -} - -config.mail = {}; -config.mail.service = process.env.COCO_MAIL_SERVICE_NAME || "Zoho"; -config.mail.username = process.env.COCO_MAIL_SERVICE_USERNAME || ""; -config.mail.password = process.env.COCO_MAIL_SERVICE_PASSWORD || ""; -config.mail.mailchimpAPIKey = process.env.COCO_MAILCHIMP_API_KEY || ''; -config.mail.mailchimpWebhook = process.env.COCO_MAILCHIMP_WEBHOOK || '/mail/webhook'; -config.mail.sendwithusAPIKey = process.env.COCO_SENDWITHUS_API_KEY || ''; - -config.queue = {}; -config.queue.accessKeyId = process.env.COCO_AWS_ACCESS_KEY_ID || ''; -config.queue.secretAccessKey = process.env.COCO_AWS_SECRET_ACCESS_KEY || ''; -config.queue.region = 'us-east-1'; -config.queue.simulationQueueName = "simulationQueue"; -config.mongoQueue = {}; -config.mongoQueue.queueDatabaseName = "coco_queue"; - -config.salt = process.env.COCO_SALT || 'pepper'; -config.cookie_secret = process.env.COCO_COOKIE_SECRET || 'chips ahoy'; - -config.isProduction = config.mongo.host != 'localhost'; - -if(!config.unittest && !config.isProduction) { - // change artificially slow down non-static requests for testing - config.slow_down = false; -} - -module.exports = config;