-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (26 loc) · 895 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
import express from "express";
import { dbConnect } from "./config/dbConnect.js";
import bodyParser from "body-parser";
import dotenv from "dotenv";
import { authRouter } from "./routes/authRoute.js";
import { productRouter } from "./routes/productRoute.js";
import { blogROuter } from "./routes/blogRoute.js";
import cookieParser from "cookie-parser";
import morgan from "morgan";
const app = express();
const PORT = process.env.PORT || 5000;
dotenv.config();
app.use(morgan("dev"));
app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.listen(PORT, () => {
console.log(`server is listening on port http://localhost:${PORT}`);
});
dbConnect();
app.use("/api/user", authRouter);
app.use("/api/product", productRouter);
app.use("/api/blog", blogROuter);
// app.use("/", (req,res)=> {
// res.send("hello from server side");
// });