From 35818d32e197903bf314fafe6231f948de6149dd Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Sun, 17 Feb 2019 22:32:21 -0700 Subject: added check for envs and mongo uri, updated readme --- web/routes/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'web/routes') 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 { -- cgit v1.2.3