-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
61 lines (49 loc) · 1.38 KB
/
index.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
52
53
54
55
56
57
58
59
60
61
var useFake = false;
var express = require('express');
var app = express();
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var session = require('express-session');
var passport = require('passport');
var moment = require('moment')
app.locals.moment = require('moment')
//var fn = require('fn');
var hbs = require('./lib/handlebar-helpers')
app.engine('handlebars', hbs.engine);
app.set('view engine', hbs.extname);
app.set('port', (process.env.PORT || 5000));
var Handlebars = require("handlebars");
var MomentHandler = require("handlebars.moment");
MomentHandler.registerHelpers(Handlebars);
var fake_account = require('./fake')
var routes = require('./routes/index');
if(useFake){
app.use(fake_account);
}
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(cookieParser());
app.use(session({
secret: 'shhhhhhhhh',
resave: true,
saveUninitialized: true,
cookie: {
maxAge: 1000 * 60 * 60 * 24 * 7
}
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(require('./lib/oauth2'));
app.use('/', routes);
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});
app.use(express.static('public/'));
app.use(function(req, res) {
res.status(400);
res.render('notFound', {
user: req.user
})
})