-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
40 lines (31 loc) · 808 Bytes
/
index.js
File metadata and controls
40 lines (31 loc) · 808 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
38
39
40
const express = require('express')
const http = require('http')
const cors = require('cors')
const passport = require('passport')
const routerApi = require('./routes')
const WebSockets = require('./services/wss.service')
const {
logErrors,
errorHandler,
boomErrorHangler,
ormErrorHandler,
} = require('./middlewares/error.handler')
const app = express()
const port = process.env.PORT || 3000
app.use(express.json())
app.use(cors())
require('./utils/auth')
app.get('/', (_req, res) => {
res.send('Chat Server API')
})
app.use(passport.initialize())
routerApi(app)
app.use(logErrors)
app.use(ormErrorHandler)
app.use(boomErrorHangler)
app.use(errorHandler)
const httpServer = http.createServer(app)
httpServer.listen(port)
httpServer.on('listening', () => {
WebSockets.init(httpServer)
})