-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
31 lines (23 loc) · 838 Bytes
/
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
const express = require("express");
const bodyParser = require("body-parser");
const path = require("path");
const cors = require("cors");
const helmet = require("helmet");
const { v1} = require("./routes");
const { validateToken, handleError } = require("./middleware");
const {morganLogger } = require("./middleware/logger");
const app = express();
app.use("/", express.static(path.join(__dirname, "../public")));
app.use(morganLogger)
.use(cors())
.use(helmet())
.use(bodyParser.urlencoded({ limit: "100mb", extended: true, parameterLimit: 50000 }))
.use(bodyParser.json({ limit: "100mb" }))
.use(express.static(path.join(__dirname, "public")))
.set("views", path.join(__dirname, "views"));
app.use(validateToken);
app.use("/v1", v1);
app.use((err, req, res, next) => {
handleError(err, res);
});
module.exports = app;