-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
51 lines (40 loc) · 1.3 KB
/
server.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
43
44
45
46
47
48
49
50
51
let express = require('express');
let review = require('./routes.js');
let path = require('path');
let logger = require('morgan');
let bodyParser = require('body-parser');
let nunjucks = require('nunjucks');
let session = require('express-session');
let LocalStrategy = require('passport-local').Strategy;
let app = express();
nunjucks.configure('views', {autoescape: true, express: app});
app.use(express.static(path.join(__dirname, 'assets')));
app.use(session({secret: 'doodoodoo'}));
app.use(logger('dev'));
app.use(function(req, res, next) {
res.locals.session = req.session;
next();
});
// The request body is received on GET or POST.
// A middleware that just simplifies things a bit.
app.use(bodyParser.json()); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));
app.listen(process.env.PORT||3000, function () {
console.log('Listening on port 3000');
});
/**Routing functions go here**/
// Get the index page:
app.get('/', (req, res) => {
//console.log(req.user.username);
if (req.user !== undefined) {
doo.getAllEvents(req, res);
} else {
res.redirect('/201504Q2');
}
});
app.get("/201504Q2", (req, res) => {
res.render("201504Q2.html")
});
app.post("/201504Q2", review.Q201504Q2);