forked from sundram2003/ClickNShop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (29 loc) · 887 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
32
33
34
35
36
const express = require("express");
const colors = require("colors");
const morgan = require("morgan");
const cors = require("cors");
const { connectDb } = require("./config/db");
const authRoutes = require("./routes/authRoutes");
const categoryRoutes = require("./routes/categoryRoutes");
const productRoutes = require("./routes/productRoutes");
require("dotenv").config();
const app = express();
//connection with DB
connectDb();
//middleware
app.use(cors());
app.use(express.json());
app.use(morgan("dev"));
//mounting routes
app.use("/api/v1/auth", authRoutes);
app.use("/api/v1/category", categoryRoutes);
app.use("/api/v1/product", productRoutes);
app.get("/", (req, res) => {
res.send({
message: "Welcome to E-Commerce Website",
});
});
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`Server is Running on ${PORT}`.bgCyan.white);
});