-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
64 lines (55 loc) · 1.57 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
60
61
62
63
64
// Importing necessary modules and packages
const express = require("express");
const app = express();
const userRoutes = require("./routes/user");
const profileRoutes = require("./routes/profile");
const courseRoutes = require("./routes/Course");
const paymentRoutes = require("./routes/Payments");
const contactUsRoute = require("./routes/Contact");
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");
// Setting up port number
const PORT = process.env.PORT || 4000;
// Loading environment variables from .env file
dotenv.config();
// Connecting to database
database.connect();
// Middlewares
app.use(express.json());
app.use(cookieParser());
app.use(
cors({
origin: "*",
credentials: true,
})
);
app.use(
fileUpload({
useTempFiles: true,
tempFileDir: "/tmp/",
})
);
// Connecting to cloudinary
cloudinaryConnect();
// Setting up 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.use("/api/v1/reach", contactUsRoute);
// Testing the server
app.get("/", (req, res) => {
return res.json({
success: true,
message: "Your server is up and running ...",
});
});
// Listening to the server
app.listen(PORT, () => {
console.log(`App is listening at ${PORT}`);
});
// End of code.