aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKumar Damani <kumar.damani@mail.utoronto.ca>2019-02-18 05:32:21 +0000
committerKumar Damani <kumar.damani@mail.utoronto.ca>2019-02-18 05:32:21 +0000
commit35818d32e197903bf314fafe6231f948de6149dd (patch)
treee2bab4e33fa4012125e4957b6bb26d665a544c0b
parent0022b41b5a1d20c60d9ffb56403150ce97153f09 (diff)
added check for envs and mongo uri, updated readme
-rw-r--r--web/README.md11
-rw-r--r--web/routes/index.js12
2 files changed, 17 insertions, 6 deletions
diff --git a/web/README.md b/web/README.md
index 244c216..b56efa5 100644
--- a/web/README.md
+++ b/web/README.md
@@ -1,14 +1,15 @@
# The web component
-## How to run in your local env:
+## How to run in your LOCAL env:
### Requirements
+
1. docker (or local mongodb install)
2. npm
#### Steps
-1. Spawn up a docker container with mongodb
+1. Spawn up a docker container with mongodb OR start mongo from local install
`docker run -d --name mymongo -p 27017:27017 mongo`
@@ -30,13 +31,13 @@
Then open your browser to `localhost:3000`
-You should be greeted with a page with a map.
+You should be greeted with a page with a map. From next time onwards, just start up the mongo container with `docker start mymongo`.
## You can view the current latest production site on Heroku (master branch)
-[here]()
+not yet.
## You can view the current latest QA site on Heroku (qa branch)
-[here]()
+https://helpthehome-qa.herokuapp.com/
diff --git a/web/routes/index.js b/web/routes/index.js
index 896fdae..73520b0 100644
--- a/web/routes/index.js
+++ b/web/routes/index.js
@@ -4,8 +4,18 @@ var router = express.Router();
// Mongoose import
var mongoose = require('mongoose');
+var env = process.env.NODE_ENV || 'development';
+var uri;
+if (env === 'development') {
+ uri = 'mongodb://localhost:27017/helpthehome'
+} else if (env === 'qa') {
+ uri = process.env.MONGODB_URI
+} else if (env === 'production') {
+ uri = ''
+}
+
// Mongoose connection to MongoDB
-mongoose.connect('mongodb://localhost:27017/helpthehome', { useNewUrlParser: true }, function (error) {
+mongoose.connect(uri, { useNewUrlParser: true }, function (error) {
if (error) {
console.log(error);
} else {