-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
59 lines (45 loc) · 1.33 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const express = require("express");
const app = express();
const userRoutes = require("./routes/User");
const profileRoutes = require("./routes/Profile");
const paymentRoutes = require("./routes/Payment");
const courseRoutes = require("./routes/Course");
const database = require("./config/database");
const cookieParser = require("cookie-parser");
const cors = require("cors");
const{cloudinaryConnect} = require("./config/cloudinary");
const fileUpload = require("express-fileupload");
const dotenv = require("dotenv");
dotenv.config();
const PORT = process.env.PORT || 4000;
database.connect();
app.use(express.json());
app.use(cookieParser());
//to entertain request from frontend
app.use(
cors({
origin:`http://localhost:${PORT}`,
credentials:true,
})
);
app.use(
fileUpload({
useTempFiles:true,
tempFileDir:"/tmp/",
})
);
cloudinaryConnect();
//mount routes
app.use("/api/v1/auth", userRoutes);
app.use("/api/v1/profile", profileRoutes);
app.use("/api/v1/course", courseRoutes);
app.use("/api/v1/payment", paymentRoutes);
app.get("/", (req,res)=>{
return res.json({
success:true,
message:"Server is up and running...",
});
});
app.listen(PORT, ()=>{
console.log(`App is running at Port ${PORT}`)
});