-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
36 lines (29 loc) · 1.1 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require('dotenv').config();
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var bodyParser = require('body-parser');
var app = express();
// Mongoose stuff
var mongoose = require('mongoose');
mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost/TripPlanner', {useMongoClient: true});
// Set up middleware
app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json({limit: "50mb"}));
app.use(bodyParser.urlencoded({limit: "50mb", extended: true, parameterLimit:50000}));
app.use(express.static(path.resolve(__dirname, 'client', 'build')));
app.use(function(req, res, next) {
// before every route, attach the flash messages and current user to res.locals
res.locals.currentUser = req.user;
next();
});
// Controllers
app.use('/auth', require('./routes/auth'));
app.use('/saved', require('./routes/saved'));
app.get('*', function(req, res, next) {
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
});
// app.listen(3000);
module.exports = app;