-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
36 lines (27 loc) · 839 Bytes
/
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
const express = require('express')
const router = require('./router/index');
const bodyParser = require('body-parser');
const app = express();
const io = require('socket.io').listen(app.listen(3000));
const Lecture = require('./utils/lecture');
const winston = require('winston');
// every request goes through the router
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
winston.add(
winston.transports.File, {
filename: './history.log',
level: 'info',
json: true,
eol: 'n', // for Windows, or `eol: ‘n’,` for *NIX OSs
timestamp: true
}
)
app.use(express.static(__dirname + '/public'));
app.use('/', router);
io.on('connection', function (socket) {
console.log('connected to socket');
winston.info('connected to socket')
});
app.set('io', io);
module.exports = app;