-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserver.js
38 lines (34 loc) · 1008 Bytes
/
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
require("dotenv").config();
const express = require("express");
const app = express();
const cors = require("cors");
const swaggerJsDoc = require("swagger-jsdoc");
const swaggerUI = require("swagger-ui-express");
const swaggerDocs = require("./swagger");
const fileUpload = require("express-fileupload");
const corsOptions = {
origin: "*",
credentials: true, //access-control-allow-credentials:true
optionSuccessStatus: 200,
};
app.use(cors(corsOptions));
app.use(fileUpload());
app.use(
express.urlencoded({ limit: "50mb", extended: false, parameterLimit: 50000 })
);
app.use(express.json({ extended: false, limit: "50mb" }));
// API Swagger documentation
var options = {
customCss: `
.swagger-ui .topbar { display: none }
`,
};
app.use("/api-docs", swaggerUI.serve, swaggerUI.setup(swaggerDocs, options));
app.use(function (req, res, next) {
res.header(
"Access-Control-Allow-Headers",
"x-access-token, Origin, Content-Type, Accept"
);
next();
});
module.exports = app;