-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (27 loc) · 1.01 KB
/
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
const dotenv = require('dotenv').config();
const express = require('express');
const app = express();
const cors = require('cors');
const swaggerUI = require('swagger-ui-express');
const startServer = require('./graphql');
const notFound = require('./middleware/notFound.js')
const handleErrors = require('./middleware/handleErrors.js')
const usersRouter = require('./controllers/users')
const channelsRouter = require('./controllers/channels')
const serversRouter = require('./controllers/servers')
const logsRouter = require('./controllers/logs')
app.use(cors());
app.options('*', cors());
app.use(express.json());
app.use('/api-docs', swaggerUI.serve, swaggerUI.setup(require('./docs/openapi.json')));
app.use('/api/clients', usersRouter)
app.use('/api/channels', channelsRouter)
app.use('/api/server', serversRouter)
app.use('/api/logs', logsRouter)
app.use(notFound)
app.use(handleErrors)
const PORT = process.env.PORT || 3001;
app.listen(PORT, () => {
console.log(`Server listening on port ${PORT}`);
startServer();
});