forked from RAnderso0325/react-calendar-app
-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.js
42 lines (34 loc) · 1.34 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
37
38
39
40
41
42
require('dotenv').config();
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var https = require('https');
var http = require('http');
var app = express();
// Mongoose stuff
var mongoose = require('mongoose');
mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost/calendardb', {useMongoClient: true});
mongoose.set('debug', true); //TODO: Remove Me for production!
// 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(cookieParser());
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('/calendar', require('./routes/calendar').router);
app.use('/calendar/event', require('./routes/event'));
app.get('*', function(req, res, next) {
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
});
module.exports = app;