-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (39 loc) · 1.46 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require('dotenv/config');
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const swaggerJsDoc = require('swagger-jsdoc');
const swaggerUi = require('swagger-ui-express');
const { errors } = require('celebrate');
const copyright = require('./routes/copyright');
const ngo = require('./routes/ngoRoutes');
const incidents = require('./routes/incidentsRoutes');
const session = require('./routes/sessionRoutes');
const app = express();
const swaggerDefinition = require('./swagger.json');
const swaggerOptions = {
swaggerDefinition,
apis: ['./routes/*.js'],
};
const swaggerSpec = swaggerJsDoc(swaggerOptions);
app.get('/api-doc.json', function (req, res) {
res.setHeader('Content-Type', 'application/json');
res.send(swaggerSpec);
});
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec, {
explorer: false,
customCss: '.swagger-ui .topbar {display :none} ',
customCssUrl: 'https://cdn.jsdelivr.net/npm/swagger-ui-themes@3.0.1/themes/3.x/theme-material.css',
customfavIcon: "https://raw.githubusercontent.com/leoronne/BeTheHero/master/assets/img/favicon.ico",
customSiteTitle: 'Be The Hero - API Documentation',
}));
app.use(cors());
app.use(express.json());
app.use('/', copyright);
app.use('/ngo', ngo);
app.use('/session', session);
app.use('/incidents', incidents);
app.use(errors());
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
});