-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
executable file
·57 lines (44 loc) · 1.41 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
52
53
54
55
56
57
/**
*
* @module server
* @author Greg Babula [[email protected]]
* @description
*
*/
'use strict';
var express = require('express');
var connect = require('connect');
var morgan = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var serveStatic = require('serve-static');
var session = require('cookie-session');
var http = require('http');
var passport = require('passport');
var path = require('path');
var User = require('./server/models/User');
var app = express();
var server = http.createServer(app);
app.set('views', __dirname + '/app/views');
app.set('view engine', 'jade');
app.use(morgan('dev'));
app.use(cookieParser());
app.use(bodyParser.json());
app.use(methodOverride());
app.use(serveStatic(path.join(__dirname, 'app')));
app.use(session({ secret: 'Cloud' }));
// setup passport
passport.use(User.localStrategy);
passport.serializeUser(User.serializeUser);
passport.deserializeUser(User.deserializeUser);
// init passport
app.use(passport.initialize());
app.use(passport.session());
// add routes
require('./server/routes.js')(app);
// server
app.set('port', process.env.PORT || 8000);
server.listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});