-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (27 loc) · 1015 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
29
30
31
32
33
34
35
require('dotenv/config');
const express = require('express');
const http = require('http');
const cors = require('cors');
const bodyParser = require('body-parser');
const { errors } = require('celebrate');
const swaggerUi = require('swagger-ui-express');
const swaggerConfiguration = require('./Swagger/swaggerConfiguration');
const { setupWebsocket } = require('./websocket');
const routes = require('./routes');
const app = express();
const server = http.Server(app);
setupWebsocket(server);
app.get('/api-doc.json', function (req, res) {
res.setHeader('Content-Type', 'application/json');
res.send(swaggerConfiguration.swaggerSpec);
});
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerConfiguration.swaggerSpec, swaggerConfiguration.swaggerConfig));
app.use(cors());
app.use(express.json());
app.use('/', routes.copyright);
app.use('/dev', routes.dev);
app.use('/session', routes.session);
app.use(errors());
const PORT = process.env.PORT || 8080;
server.listen(PORT, () => {
});