aboutsummaryrefslogtreecommitdiff
path: root/web/app.js
diff options
context:
space:
mode:
authorKumar Damani <kumar.damani@mail.utoronto.ca>2019-02-28 07:40:15 +0000
committerKumar Damani <kumar.damani@mail.utoronto.ca>2019-02-28 07:40:15 +0000
commit0a61d18ba0088b378fcfab6498b3a1c42f9c029f (patch)
tree2dc863825deba71b4e683619705f02a8d685967f /web/app.js
parent197f2f42091b691feb7c31308dbfc9ddde07a10f (diff)
sending geo data to front end, displaying it as markers, and taken out schema defs from index into models folder
Diffstat (limited to 'web/app.js')
-rw-r--r--web/app.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/web/app.js b/web/app.js
index ab7aed4..f0ae3a5 100644
--- a/web/app.js
+++ b/web/app.js
@@ -3,6 +3,7 @@ var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
+var mongoose = require('mongoose');
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
@@ -19,6 +20,29 @@ app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
+var env = process.env.NODE_ENV || 'development';
+var uri;
+if (env === 'development') {
+ uri = 'mongodb://localhost:27017/helpthehome'
+ // use for small testing only if really necessary
+ // uri = 'mongodb+srv://development:dreamteam@cluster0-krnr4.mongodb.net/helpthehome?retryWrites=true'
+} else if (env === 'qa') {
+ uri = process.env.MONGODB_URI
+} else if (env === 'production') {
+ uri = ''
+}
+
+// Mongoose connection to MongoDB
+mongoose.connect(uri, { useNewUrlParser: true }, function (error) {
+ if (error) {
+ console.log(error);
+ console.log("App was not able to connect to the mongo server!");
+ console.log("... double check that the mongo server is running locally");
+ } else {
+ console.log(`connected to ${uri}`);
+ }
+});
+
app.use('/', indexRouter);
app.use('/users', usersRouter);