-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
37 lines (27 loc) · 839 Bytes
/
app.js
File metadata and controls
37 lines (27 loc) · 839 Bytes
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 http = require('http');
const expressConfig = require('./config/express');
const connectDB = require('./config/database');
const { connect: connectSocket, socket } = require('./config/socket')
const routes = require('./routes');
const { log } = require('./utils/logger')
const app = express();
const server = http.Server(app);
expressConfig(app);
connectSocket(server);
const PORT = process.env.PORT;
// Start server
server.listen(PORT, () => {
// connect to database
connectDB();
// Routes
routes(app);
socket.io.on('connection', (socket) => {
log.info(`Socket Connected: ${socket.id}`);
socket.on('disconnect', () => {
log.info(`Socket Disconnect: ${socket.id}`);
})
})
log.info(`Server running at http://localhost:${PORT}/`);
});
module.exports = app;