-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCourse.js
105 lines (91 loc) · 3.55 KB
/
Course.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Import the required modules
const express = require("express");
const router = express.Router();
// Import the Controllers
// Course Controllers Import
const {
createCourse,
showAllCourses,
editCourse,
getCourseDetails,
getFullCourseDetails,
getInstructorCourses,
deleteCourse,
} = require("../controllers/Course");
// Categories Controllers Import
const {
showAllCategories,
createCategory,
categoryPageDetails,
} = require("../controllers/Category");
// Sections Controllers Import
const {
createSection,
updateSection,
deleteSection,
} = require("../controllers/Section");
// Sub-Sections Controllers Import
const {
createSubSection,
updateSubSection,
deleteSubSection,
} = require("../controllers/Subsection");
// Rating Controllers Import
const {
createRating,
getAverageRating,
getAllRating,
} = require("../controllers/RatingAndReview");
const { updateCourseProgress } = require("../controllers/courseProgress");
// Importing Middlewares
const {
auth,
isInstructor,
isStudent,
isAdmin,
} = require("../middlewares/auth");
// ********************************************************************************************************
// Course routes
// ********************************************************************************************************
// Courses can Only be Created by Instructors
router.post("/createCourse", auth, isInstructor, createCourse);
//Add a Section to a Course
router.post("/addSection", auth, isInstructor, createSection);
// Update a Section
router.post("/updateSection", auth, isInstructor, updateSection);
// Delete a Section
router.post("/deleteSection", auth, isInstructor, deleteSection);
// Edit Sub Section
router.post("/updateSubSection", auth, isInstructor, updateSubSection);
// Delete Sub Section
router.post("/deleteSubSection", auth, isInstructor, deleteSubSection);
// Add a Sub Section to a Section
// router.post("/addSubSection", auth, isInstructor, createSubSection);
// Get all Registered Courses
router.get("/showAllCourses", showAllCourses);
// Get Details for a Specific Courses
router.post("/getCourseDetails", getCourseDetails);
// Get Details for a Specific Courses
router.post("/getFullCourseDetails", auth, getFullCourseDetails);
// Edit Course routes
router.post("/editCourse", auth, isInstructor, editCourse);
// Get all Courses Under a Specific Instructor
router.get("/getInstructorCourses", auth, isInstructor, getInstructorCourses);
// Delete a Course
router.delete("/deleteCourse", deleteCourse);
router.post("/updateCourseProgress", auth, isStudent, updateCourseProgress);
// ********************************************************************************************************
// Category routes (Only by Admin)
// ********************************************************************************************************
// Category can Only be Created by Admin
// Put IsAdmin Middleware here
router.post("/createCategory", auth, isAdmin, createCategory);
router.get("/showAllCategories", showAllCategories);
router.post("/getCategoryPageDetails", categoryPageDetails);
// ********************************************************************************************************
// Rating and Review
// ********************************************************************************************************
router.post("/createRating", auth, isStudent, createRating);
router.get("/getAverageRating", getAverageRating);
router.get("/getReviews", getAllRating);
module.exports = router;