1
+ // Import the required modules
2
+ const express = require ( "express" )
3
+ const router = express . Router ( )
4
+
5
+ // Import the Controllers
6
+
7
+ // Course Controllers Import
8
+ const {
9
+ createCourse,
10
+ showAllCourses,
11
+ getCourseDetails,
12
+ } = require ( "../controllers/Course.controller" )
13
+
14
+
15
+ // Categories Controllers Import
16
+ const {
17
+ showAllCategories,
18
+ createCategory,
19
+ categoryPageDetails,
20
+ } = require ( "../controllers/Category.controller" )
21
+
22
+ // Sections Controllers Import
23
+ const {
24
+ createSection,
25
+ updateSection,
26
+ deleteSection,
27
+ } = require ( "../controllers/Section.controller" )
28
+
29
+ // Sub-Sections Controllers Import
30
+ const {
31
+ createSubSection,
32
+ updateSubSection,
33
+ deleteSubSection,
34
+ } = require ( "../controllers/Subsection.controller" )
35
+
36
+ // Rating Controllers Import
37
+ const {
38
+ createRating,
39
+ getAverageRating,
40
+ getAllRating,
41
+ } = require ( "../controllers/RatingAndReview.controller" )
42
+
43
+ // Importing Middlewares
44
+ const { auth, isInstructor, isStudent, isAdmin } = require ( "../middlewares/auth.middleware" )
45
+
46
+
47
+
48
+ // Courses can Only be Created by Instructors
49
+ router . post ( "/createCourse" , auth , isInstructor , createCourse )
50
+ //Add a Section to a Course
51
+ router . post ( "/addSection" , auth , isInstructor , createSection )
52
+ // Update a Section
53
+ router . post ( "/updateSection" , auth , isInstructor , updateSection )
54
+ // Delete a Section
55
+ router . post ( "/deleteSection" , auth , isInstructor , deleteSection )
56
+ // Edit Sub Section
57
+ router . post ( "/updateSubSection" , auth , isInstructor , updateSubSection )
58
+ // Delete Sub Section
59
+ router . post ( "/deleteSubSection" , auth , isInstructor , deleteSubSection )
60
+ // Add a Sub Section to a Section
61
+ router . post ( "/addSubSection" , auth , isInstructor , createSubSection )
62
+ // Get all Registered Courses
63
+ router . get ( "/getAllCourses" , showAllCourses )
64
+ // Get Details for a Specific Courses
65
+ router . post ( "/getCourseDetails" , getCourseDetails )
66
+
67
+ // ********************************************************************************************************
68
+ // Category routes (Only by Admin)
69
+ // ********************************************************************************************************
70
+ // Category can Only be Created by Admin
71
+ // TODO: Put IsAdmin Middleware here
72
+ router . post ( "/createCategory" , auth , isAdmin , createCategory )
73
+ router . get ( "/showAllCategories" , showAllCategories )
74
+ router . post ( "/getCategoryPageDetails" , categoryPageDetails )
75
+
76
+
77
+ router . post ( "/createRating" , auth , isStudent , createRating )
78
+ router . get ( "/getAverageRating" , getAverageRating )
79
+ router . get ( "/getReviews" , getAllRatingReview )
80
+
81
+ module . exports = router
0 commit comments