-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (28 loc) · 1.09 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
const express = require('express');
const app = express();
const server = require('http').Server(app);
const bodyParser = require('body-parser');
const io = require('socket.io')(server);
// Other required dependencies
const session = require('cookie-session');
const iosession = require('express-session')({
secret: 'pseudo',
resave: true,
saveUninitialized: true
});
const sharedsession = require("express-socket.io-session");
app.use(session({ secret: 'todolistinsession' }))
.use(iosession)
.use('/js', express.static(__dirname + '/node_modules/bootstrap/dist/js'))
.use('/js', express.static(__dirname + '/node_modules/jquery/dist'))
.use('/css', express.static(__dirname + '/node_modules/bootstrap/dist/css'))
.use(bodyParser.urlencoded({ extended: false }));
const routes = require('./routes')(io, iosession);
app.use('/', routes);
const shared = io.of('/shared/');
const sharedSocket = require('./sharedSocket')(shared, iosession);
shared.use(sharedsession(iosession));
shared.on('connection', sharedSocket);
server.listen(8080, () => {
console.info('Server started on port 8080');
});