-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
52 lines (43 loc) · 1.23 KB
/
index.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
47
48
49
50
51
52
require("dotenv").config()
const express = require("express")
const app = express()
const bodyParser = require("body-parser")
const usersRoutes = require("./routes/users.routes")
const authRoutes = require("./routes/auth.routes")
const productsRoutes = require("./routes/products.routes")
const addressRoutes = require("./routes/address.routes")
const ordersRoutes = require("./routes/orders.routes")
const paymentRoutes = require("./routes/payment.routes")
const invalidRoutes = require("./routes/404.routes")
const helmet = require("helmet")
const xss = require("xss-clean")
const cors = require("cors")
const fileUpload = require("express-fileupload")
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
app.use(helmet())
app.use(xss())
app.use(cors())
app.use(
fileUpload({
useTempFiles: true,
tempFileDir: "/tmp/",
})
)
app.use(usersRoutes)
app.use(authRoutes)
app.use(productsRoutes)
app.use(addressRoutes)
app.use(ordersRoutes)
app.use(paymentRoutes)
// Home
app.get("/", (req, res) => {
res.send("API For Blanja App")
})
// Other routes
app.use(invalidRoutes)
app.listen(8000, () => {
console.log("App running in port 8000")
})