-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (26 loc) · 773 Bytes
/
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
import dotenv from "dotenv"
dotenv.config()
import express from 'express'
import { connectDb } from "./Database.js";
import {authRouter} from "./routes/authRoutes.js";
import bodyParser from "body-parser"
import cors from "cors";
import categoryRouter from "./routes/categoryRoutes.js";
import productRouter from "./routes/productRoutes.js";
const app=express();
//middleware
app.use(cors());
app.use(bodyParser.json())
//routes
app.use("/api/v1/auth",authRouter);
app.use ("/api/v1/category",categoryRouter)
app.get('/',(req,res)=>{
res.send("hello from node")
})
app.use("/api/v1/product",productRouter)
const port = process.env.PORT || 5000
connectDb().then(()=>{
app.listen(port,()=>{
console.log(`server is running on port ${port}`)
})
});