From 0a63131f12aec1540d60c0c9ef1ca9776f1d2855 Mon Sep 17 00:00:00 2001 From: kdam0 Date: Mon, 2 Jan 2017 13:11:32 -0500 Subject: add confg vars support to use dev db --- README.md | 2 +- app.js | 2 +- node_simple.js | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e364d16..1528849 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ In order to run the web app locally from your computer please follow the followi 1. Clone the repository into your desired directory from: https://github.com/HumairAK/solutions_repo 2. Make sure node.js and npm are installed on your computer. If not, the easiest way to do this is using Homebrew. 3. Run: npm install from the root directory -4. Run: node app.js to run the server +4. Run: NODE_ENV=staging node app.js to run the server 5. Open the browser to http://localhost:3000/ ## Usage and Features diff --git a/app.js b/app.js index f8e2ab5..9a7aa85 100644 --- a/app.js +++ b/app.js @@ -105,7 +105,7 @@ app.use(function(error, req, res, next) { dbFile.setupDB(function (success, mssg) { if (success) { // db establiseh server.listen(port, function(){ // now accept connections - console.log('listening on port 8080'); + console.log('listening on port 3000'); }); } else { diff --git a/node_simple.js b/node_simple.js index 2f49360..0ccf76a 100644 --- a/node_simple.js +++ b/node_simple.js @@ -103,8 +103,14 @@ var _ = require('underscore'); var db; // Standard URI format: mongodb://[dbuser:dbpassword@]host:port/dbname -var uri = exports.uri = 'mongodb://general:assignment4@ds057862.mlab.com:57862/solutions_repo'; - +if (NODE_ENV == 'staging') { + var uri = exports.uri = 'mongodb://root:solutions_repo@ds023624.mlab.com:23624/solutions_staging'; +} else if (NODE_ENV == 'production') { + var uri = exports.uri = 'mongodb://general:assignment4@ds057862.mlab.com:57862/solutions_repo'; +} else if (NODE_ENV == 'development') { + // Keep this for testing on local machine, do not remove. - Humair + //var uri = 'mongodb://localhost:27017/db'; +} // Keep this for testing on local machine, do not remove. - Humair //var uri = 'mongodb://localhost:27017/db'; -- cgit v1.2.3