This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
53 lines (49 loc) · 1.73 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const dotenv = require("dotenv");
dotenv.config();
const express = require("express");
const { ConnectMongo } = require("./database/connectMongo");
const app = express();
const PORT = 5000;
const auth = require("./route/api/auth");
const user = require("./route/api/user");
const role = require("./route/api/role");
const product = require("./route/api/product");
const category = require("./route/api/category");
const cart = require("./route/api/cart");
const order = require("./route/api/order");
const billing = require("./route/api/billing");
const promotion = require("./route/api/promotion");
const feedBack = require("./route/api/feedBack");
const pay = require("./route/api/pay");
const { errorMiddleware } = require("./middlewares/errorMiddleware");
// Connect to MongoDB
ConnectMongo.getConnect();
// All middlewares
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
);
next();
});
// All routes
app.use(express.json());
app.use("/api/v1/auth", auth); //dang ky,dang nhap, quen mk
app.use("/api/v1/user", user); //active tk,...
app.use("/api/v1/role", role); //phân quyền
app.use("/api/v1/product", product); //get product(by id ,all) , thêm product, xóa product
app.use("/api/v1/category", category); //(loại)
app.use("/api/v1/cart", cart); //(giỏ hàng)
app.use("/api/v1/order", order);
app.use("/api/v1/billing", billing);
app.use("/api/v1/promotion", promotion);
app.use("/api/v1/feedBack", feedBack);
app.use("/api/v1/pay", pay);
app.use(errorMiddleware);
// Start server
const server = app.listen(PORT, () => {
console.log(`server is running on localhost:${PORT}`);
});
//--
//🌏 🌊 🌉 🌈