-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
52 lines (44 loc) · 1.2 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
47
48
49
50
51
52
require("dotenv").config();
const express = require("express");
const app = express();
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const cors = require("cors");
const cookieParser = require("cookie-parser");
// ROUTES
const authRoutes = require("./routes/auth");
const userRoutes = require("./routes/user");
const catagoryRoute = require("./routes/catagory");
const productRoute=require("./routes/product")
const orderRoute=require("./routes/order")
const paymentRoute=require("./routes/payment")
// DB CONNECTION
mongoose
.connect(process.env.DATABASE, {
useUnifiedTopology: true,
useNewUrlParser: true,
useCreateIndex: true,
})
.then(() => {
console.log("DB CONNECTED");
})
.catch(() => {
console.log("OOPSS !! SOMETHING WENT WRONG");
});
// PORT
const port = 7000;
// MIDDLEWARES
app.use(bodyParser.json());
app.use(cors());
app.use(cookieParser());
// MY ROUTES
app.use("/api", authRoutes);
app.use("/api", userRoutes);
app.use("/api", catagoryRoute);
app.use("/api", productRoute);
app.use("/api", orderRoute);
app.use("/api",paymentRoute)
// STARTING A SERVER
app.listen(port, () => {
console.log(`Server is Up & Running at ${port}`);
});