-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (26 loc) · 805 Bytes
/
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
import express from "express";
import cors from "cors";
import dotenv from "dotenv";
import helmet from "helmet";
import userRoute from "./routes/user.js";
import authRoute from "./routes/auth.js";
import productRoute from "./routes/product.js";
import cartRoute from "./routes/cart.js";
import orderRoute from "./routes/order.js";
import { DBconnect } from "./config/database.js";
dotenv.config();
DBconnect();
const app = express();
app.use(cors());
app.use(helmet());
app.use(express.json());
// routes
app.use("/api/auth", authRoute);
app.use("/api/users", userRoute);
app.use("/api/products", productRoute);
app.use("/api/carts", cartRoute);
app.use("/api/orders", orderRoute);
const port = process.env.PORT || 5000;
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});