-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (27 loc) · 789 Bytes
/
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
const app = require('express')();
const logger = require('morgan');
const cors = require('cors');
const bodyParser = require('body-parser');
const server = require('http').Server(app);
const io = require('./server/socket')(server);
app.use(cors());
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
//@TODO: needs to be after db query
app.put('/api/games/:gameId', (req, res, next) => {
const gameId = req.params.gameId;
io.to(gameId).emit('updateGame', req.body);
console.log('MESSAGE updateGame', req.body)
next()
});
require('./server/routes')(app, io);
app.get('*', (req, res) => res
.status(200)
.send({
data: {
message: 'Welcome to the beginning of nothingness.'}
}
)
);
module.exports = server;