0% found this document useful (0 votes)
50 views2 pages

Server Index

This document defines the server configuration and routes for an education application. It requires Express and sets up middleware for parsing JSON, cookies, files, and CORS. It connects to a MongoDB database and Cloudinary. Routes are defined for authentication, profiles, courses, and payments. The server listens on port 4000 and a default route returns a success message. Environment variables are configured for mail, JWT, file storage, Razorpay, and MongoDB in a separate .env file.

Uploaded by

Sameer Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views2 pages

Server Index

This document defines the server configuration and routes for an education application. It requires Express and sets up middleware for parsing JSON, cookies, files, and CORS. It connects to a MongoDB database and Cloudinary. Routes are defined for authentication, profiles, courses, and payments. The server listens on port 4000 and a default route returns a success message. Environment variables are configured for mail, JWT, file storage, Razorpay, and MongoDB in a separate .env file.

Uploaded by

Sameer Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

StudyByte\server\index.

js

1 const express=require("express");
2 const app=express();
3
4 const userRoute=require('./routes/User');
5 const profileRoute=require('./routes/Profile');
6 const paymentRoute=require('./routes/Payments');
7 const courseRoute=require('./routes/Course');
8
9 const database=require("./config/database");
10 const cookieParser=require("cookie-parser");
11 const cors=require("cors");
12 const {cloudinaryConnect}=require("./config/cloudinary");
13 const fileUpload=require("express-fileupload");
14 const dotenv=require("dotenv");
15 [Link]();
16 const PORT=[Link]||3000;
17 // connect databse
18 [Link]();
19 // middleware
20 [Link]([Link]());
21 [Link](cookieParser());
22 [Link](
23 cors({
24 origin:"*",
25 credentials:true,
26 })
27 )
28 [Link](
29 fileUpload({
30 useTempFiles:true,
31 tempFileDir:"/tmp",
32 })
33 )
34 // cloudinary connection
35 cloudinaryConnect();
36 // routes
37 [Link]("/api/v1/auth",userRoute);
38 [Link]("/api/v1/profile",profileRoute);
39 [Link]("/api/v1/course",courseRoute);
40 [Link]("/api/v1/payment",paymentRoute);
41
42 // default route
43 [Link]("/",(req,res)=>{
44 return [Link]({
45 success:true,
46 message:"your server is up and running....."
47 })
48 })
49
50 // activate the server at port no 4000
51 [Link](PORT,()=>{
52 [Link](`app is running ${PORT}`);
53 })
StudyByte\server\.env

1 MAIL_HOST = [Link]
2 MAIL_USER = your email
3 MAIL_PASS = emal passkey
4 JWT_SECRET = "sameer"
5 FOLDER_NAME = "Sameer"
6 RAZORPAY_KEY = rzp_test_5Lh9H913li...
7 RAZORPAY_SECRET = H1KcjVIPs17LK9MhPK4N...
8 CLOUD_NAME = sameerkhan
9 API_KEY = 1572523684794...
10 API_SECRET = Ys9CAE-qVh-RQRcEyVGUR-A....
11 REACT_APP_FRONTEND_URL=[Link]
12
13 MONGODB_URL="mongodb+srv://sameerkhann:TooE7b7ksfz@[Link]/edtech"
14 PORT=4000

You might also like