-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (27 loc) · 838 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
36
37
38
39
require('dotenv').config();
const express = require('express');
const cors = require('cors');
const routes = require('./app/routes');
const middlewares = require('./app/middlewares');
const swaggerUi = require('swagger-ui-express');
const swaggerFile = require('./swagger_output.json');
const app = express();
const port = process.env.PORT || 3000;
const host = '0.0.0.0';
app.use(cors());
app.disable('x-powered-by');
app.use(express.json());
app.use(
express.urlencoded({
extended: true,
})
);
app.get('/', (_req, res) => {
// #swagger.description = 'Root route, healthcheck'
return res.status(200).send('It works');
});
app.use(routes);
app.use('/docs', swaggerUi.serve, swaggerUi.setup(swaggerFile));
app.use(middlewares.errorMiddleware);
app.listen(port, host);
console.log('Server listening to port', port);