aboutsummaryrefslogtreecommitdiff
path: root/web/routes
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 /web/routes
parent0022b41b5a1d20c60d9ffb56403150ce97153f09 (diff)
added check for envs and mongo uri, updated readme
Diffstat (limited to 'web/routes')
-rw-r--r--web/routes/index.js12
1 files changed, 11 insertions, 1 deletions
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 {