-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
48 lines (36 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
39
40
41
42
43
44
45
46
const express = require("express")
require("dotenv").config();
const app = express()
var morgan = require("morgan")
const cookieParser = require("cookie-parser")
const fileUpload = require("express-fileupload")
//for swagger documentation
const swaggerUi = require("swagger-ui-express");
const YAML = require("yamljs");
const swaggerDocument = YAML.load("./swagger.yaml");
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
//regular middleware
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
//cookies and file middleware
app.use(cookieParser())
app.use(fileUpload({
useTempFiles: true,
tempFileDir: "/temp/",
}))
//morgan middleware
app.use(morgan('tiny'))
//import all routes here
const home = require("./routes/home")
const user = require("./routes/userRoute");
const product = require("./routes/productRoute");
const payment = require("./routes/paymentRoute");
const order = require("./routes/orderRoute");
//router middleware
app.use("/api/v1", home)
app.use("/api/v1", user)
app.use("/api/v1", product)
app.use("/api/v1", payment)
app.use("/api/v1", order)
//export app js
module.exports = app