-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
62 lines (45 loc) · 1.41 KB
/
app.js
File metadata and controls
62 lines (45 loc) · 1.41 KB
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
52
53
54
55
56
57
58
59
60
const express = require('express');
const cors = require('cors');
const app = express();
const swaggerUI = require('swagger-ui-express');
const swaggerJsDoc = require('swagger-jsdoc');
const PORT = 4000 || process.env.PORT;
const errorRouter = require('./routes/error.js')
const flowerror = require('./docs/errors/getFlowError');
const integrationerror = require('./docs/errors/getIntegrationError');
const FlowSchema = require('./docs/components/schemas/Flow')
const IntegrationSchema = require('./docs/components/schemas/Integration')
app.use(cors())
app.use(express.json())
app.use('/errors',errorRouter)
const options = {
apis : ["./routes/error.js" ],
definition : {
openapi:"3.0.0",
info : {
title : "Error API",
version : "1.0.0",
description: "A simple error api in express js",
},
servers : [
{
url : "http://localhost:4000"
}
],
components: {
schemas : {
Flow : FlowSchema,
Integration : IntegrationSchema,
}
},
paths : {
"/errors/flowerror" : flowerror,
"/errors/integrationerror" : integrationerror,
}
},
}
const specs = swaggerJsDoc(options)
app.use('/errorapis' , swaggerUI.serve , swaggerUI.setup(specs) )
app.listen(PORT, ()=>{
console.log('server is running')
})