-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
38 lines (28 loc) · 1.14 KB
/
app.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
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const { clientApiKeyValidation } = require('./src/common/authUtils');
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./api-doc/openapi.json');
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(cors());
const router = express.Router();
router.use(clientApiKeyValidation);
router.use(function(req, res, next) {
next();
});
router.get('/', function(req, res) {
res.json({ message: 'Hooray! Welcome to the API!' });
});
router.use('/words', require('./src/routers/word.js'));
router.use('/batch', require('./src/routers/batch.js'));
router.use('/random', require('./src/routers/random.js'));
router.use('/search', require('./src/routers/search'));
router.use('/health', require('./src/routers/healthcheck'));
router.use('/tim', require('./src/routers/api-doc'));
app.use('/api', router);
app.use('/doc', require('./src/routers/api-doc'));
app.use('/', swaggerUi.serve, swaggerUi.setup(swaggerDocument, { explorer: false }));
module.exports = app;