forked from Quartz1605/CourseSellingWebsiteBackend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (20 loc) · 690 Bytes
/
index.js
File metadata and controls
34 lines (20 loc) · 690 Bytes
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
import express from "express";
import mongoose from "mongoose";
import { userRouter } from "./routes/user.js";
import { adminRouter } from "./routes/admin.js";
import { coursesRouter } from "./routes/courses.js";
import dotenv from "dotenv"
dotenv.config()// Yeh ek hi baar karna padta hai no need to do baar baar.
mongoose.connect(process.env.MONGO_URL)
// We are using it as a middleware in here,.use() hai yaad rakhna.
const app = express();
app.use(express.json());
app.use("/user",userRouter)
app.use("/admin",adminRouter)
app.use("/",coursesRouter)
app.get("/",(req,res) => {
res.send("hi user");
})
app.listen(3000,() => {
console.log(`http://localhost:3000/`)
})