-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
56 lines (48 loc) · 1.29 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
56
/**
* Initialize middleware
*/
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var errorHandler = require('errorhandler');
var path = require('path');
// TODO: MemoryStore isn't fit for prod, switch to Redis store, make sure compat w/ Socket.io
var session = require('express-session')({
secret: process.env.EXPRESS_SESSION_SECRET,
resave: false,
saveUninitialized: true
});
/**
* Create Express app
*/
var express = require('express');
var app = express();
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(cookieParser(process.env.EXPRESS_SESSION_SECRET));
app.use(express.static(__dirname + '/public'));
app.use(session);
/**
* Setup server for Socket.io
*/
var server = app.listen(app.get('port'));
/**
* Initialize Socket.io server
*/
var io = require('./config/socket');
io(server, session);
/**
* Controllers
*/
var homeController = require('./controllers/home');
var dashboardController = require('./controllers/dashboard');
/**
* Assign routes
*/
app.get('/', homeController.getHome);
app.post('/', homeController.postHome);
app.get('/dashboard', dashboardController.getDashboard);