-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.js
51 lines (31 loc) · 1012 Bytes
/
node.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
// take from npm docs
require('dotenv').config()
console.log(process.env.MONGO_URL)
const express=require("express");
const mongoose=require("mongoose");
// const jwt=require("jsonwebtoken");
// const JWT_SECRET="puja123";
// const {createUserRoutes, userRouter}=require("./routes/user");
// const {createCourseRoutes}=require("./routes/courses");
const {userRouter}=require("./routes/user");
const {courseRouter}=require("./routes/course");
const {adminRouter}=require("./routes/admin");
const app=express();
app.use(express.json());
//better way
app.use("/api/v1/user",userRouter);
app.use("/api/v1/course",courseRouter);
app.use("/api/v1/admin",adminRouter);
// createUserRoutes(app);
// createCourseRoutes(app);
//Routing in express , the express Router
// app.use(express.json());
// function auth(req,res,next){
// }
//first it will run
async function main(){
await mongoose.connect(process.env.MONGO_URL)
app.listen(3000);
console.log("Listening on port 3000");
}
main();