-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (22 loc) · 867 Bytes
/
index.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
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const dotenv = require('dotenv').config();
const SocketService = require('./services/socket')
const http = require('http')
const userRoutes = require('./routes/userRoutes')
const channelRoutes = require('./routes/channelRoutes')
const messageRoutes = require('./routes/msgsRoutes')
const server = express();
const httpServer = http.createServer(server)
const socketService = new SocketService();
socketService.init(httpServer);
socketService.initListeners();
server.use(cors());
server.use(bodyParser.json());
server.use('/users', userRoutes)
server.use('/channels', channelRoutes)
server.use('/message', messageRoutes)
httpServer.listen(process.env.PORT || 3001, () => {
console.log('Socket server started on port:', process.env.PORT || 3001);
});