-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (40 loc) · 1.17 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
const express = require("express");
const app = express();
const dotenv = require("dotenv");
//importing Routes
const UserRoute = require("./Router/UserRoute");
//Auth Router
const AuthRouter = require("./Router/AuthRoute");
//product Router
const ProductRouter = require("./Router/ProductRoute");
//order Router
const OrderRouter = require("./Router/OrderRoute");
//Coupons Router
const CouponsRouter = require("./Router/CouponsRoute");
//env config
dotenv.config();
//gettig momgoose to connect to the db
const mongoose = require("mongoose");
//Playing with the Router
// Stop the Procstination
//Connecting application to the Mongo db Atlas Server
mongoose
.connect(process.env.MONGO_URL)
.then(() => console.log("Success db Connection"))
.catch((err) => console.log(err));
//middleware
app.use(express.json());
//AuthbLayer
app.use("/api/auth", AuthRouter);
//User Layer
app.use("/api/user", UserRoute);
//Product Layer
app.use("/api/product", ProductRouter);
//ODer Layer
app.use("/api/order/", OrderRouter);
// Coupons Layer
app.use("/api/coupons", CouponsRouter);
//listining
app.listen(process.env.PORT || 5000, () => {
console.log("Listning from Backend . . .");
});