-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
39 lines (30 loc) · 1.06 KB
/
server.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
const express = require('express')
const cors = require('cors')
const applications = require('./api/route/applications')
const user = require('./api/route/user')
const auth = require('./api/middleware/auth')
const adminauth = require('./api/middleware/adminauth')
const swaggerJsDoc = require('swagger-jsdoc')
const swaggerUI = require('swagger-ui-express')
const swaggerOptions = {
definition: {
openapi: "3.0.0",
info: {
title: 'Trading License API',
version: '1.0.0',
description: 'Express API for the trading license department'
}
},
apis: ['api/route/*.js']
}
const openapiSpecification = swaggerJsDoc(swaggerOptions)
console.log(openapiSpecification)
const app = express()
app.use(cors())
app.use(express.json())
app.use('/api-docs', swaggerUI.serve, swaggerUI.setup(openapiSpecification))
app.use("/api/v1/applications", applications)
app.use("/api/v1/user", user)
app.use(express.static('images'))
app.use("*", (req, res) => res.status(404).json({ error: "404 Page not found" }))
module.exports = app