-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
55 lines (47 loc) · 1.96 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
43
44
45
46
47
48
49
50
51
52
53
54
55
var express = require('express')
, http = require('http')
, passport = require('passport')
, path = require('path')
, morgan = require('morgan')
, bodyParser = require('body-parser')
, methodOverride = require('method-override')
, cookieParser = require('cookie-parser')
, cookieSession = require('cookie-session')
, session = require('express-session')
, csrf = require('csurf')
, User = require('./models/User.js');
var app = module.exports = express();
app.set('views', __dirname + '/client/views');
app.set('view engine', 'jade');
app.use(morgan('dev'));
app.use(bodyParser.urlencoded());
app.use(bodyParser.json());
app.use(methodOverride());
app.use(express.static(path.join(__dirname, 'client')));
app.use(cookieParser());
app.use(session(
{
secret: process.env.COOKIE_SECRET || "Superdupersecret"
}));
var env = process.env.NODE_ENV || 'development';
if ('development' === env || 'production' === env) {
app.use(csrf());
app.use(function(req, res, next) {
res.cookie('XSRF-TOKEN', req.csrfToken());
next();
});
}
app.use(passport.initialize());
app.use(passport.session());
passport.use(User.localStrategy);
// passport.use(User.twitterStrategy()); // Comment out this line if you don't want to enable login via Twitter
// passport.use(User.facebookStrategy()); // Comment out this line if you don't want to enable login via Facebook
// passport.use(User.googleStrategy()); // Comment out this line if you don't want to enable login via Google
// passport.use(User.linkedInStrategy()); // Comment out this line if you don't want to enable login via LinkedIn
passport.serializeUser(User.serializeUser);
passport.deserializeUser(User.deserializeUser);
require('./routes')(app);
app.set('port', process.env.PORT || 5000);
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});