Initializes the LessonController with required service dependencies.
Prisma database client for service layer initialization
Creates a new lesson within a specified module with comprehensive validation.
Extracts module ID from URL parameters, validates request body against CreateLessonSchema, delegates lesson creation to the service layer, and returns a standardized API response with HTTP 201 status on successful creation.
Express request object containing moduleId in params and lesson data in body
Express response object for sending HTTP response
Express next function for error handling middleware
Resolves when response is sent or error is passed to middleware
Retrieves a single lesson by its unique identifier with comprehensive validation. Uses composite key lookup to prevent horizontal access vulnerabilities.
Extracts lesson ID and module ID from URL parameters, validates parameter presence, delegates lesson retrieval to the service layer, and returns a standardized API response with HTTP 200 status containing the lesson data.
Express request object containing lesson ID and module ID in params
Express response object for sending HTTP response
Express next function for error handling middleware
Resolves when response is sent or error is passed to middleware
Retrieves paginated lessons belonging to a specific module with query support.
Extracts module ID from URL parameters, processes query parameters for pagination and sorting, delegates lesson retrieval to the service layer, and returns a standardized API response with HTTP 200 status. Includes pagination metadata in response headers for client consumption.
Express request object containing moduleId in params and query options
Express response object for sending HTTP response with pagination headers
Express next function for error handling middleware
Resolves when response is sent or error is passed to middleware
Updates an existing lesson with partial data and comprehensive validation. Uses composite key lookup to prevent horizontal access vulnerabilities.
Extracts lesson ID and module ID from URL parameters, validates request body against UpdateLessonSchema, filters out undefined values from update data, delegates lesson update to the service layer, and returns a standardized API response with HTTP 200 status containing updated lesson data.
Express request object containing lesson ID and module ID in params and update data in body
Express response object for sending HTTP response
Express next function for error handling middleware
Resolves when response is sent or error is passed to middleware
Permanently deletes a lesson and all its associated exercise assignments. Uses composite key lookup to prevent horizontal access vulnerabilities.
Extracts lesson ID and module ID from URL parameters, validates parameter presence, delegates lesson deletion to the service layer, and returns a standardized API response with HTTP 204 status indicating successful deletion without content.
Express request object containing lesson ID and module ID in params
Express response object for sending HTTP response
Express next function for error handling middleware
Resolves when response is sent or error is passed to middleware
Assigns an exercise to a lesson at a specific order position with comprehensive validation.
Extracts lesson ID from URL parameters, validates request body against AssignExerciseToLessonSchema, delegates exercise assignment to the service layer, and returns a standardized API response with HTTP 201 status containing the created lesson-exercise assignment relationship.
Express request object containing lessonId in params and assignment data in body
Express response object for sending HTTP response
Express next function for error handling middleware
Resolves when response is sent or error is passed to middleware
Removes an exercise assignment from a lesson with comprehensive validation.
Extracts lesson ID and exercise ID from URL parameters, validates parameter presence, delegates exercise unassignment to the service layer, and returns a standardized API response with HTTP 204 status indicating successful removal without content.
Express request object containing lessonId and exerciseId in params
Express response object for sending HTTP response
Express next function for error handling middleware
Resolves when response is sent or error is passed to middleware
Retrieves all exercises assigned to a specific lesson in their defined order.
Extracts lesson ID from URL parameters, validates parameter presence, delegates exercise retrieval to the service layer, and returns a standardized API response with HTTP 200 status containing the ordered list of lesson-exercise assignments.
Express request object containing lessonId in params
Express response object for sending HTTP response
Express next function for error handling middleware
Resolves when response is sent or error is passed to middleware
Reorders exercises within a lesson by updating their position sequence.
Extracts lesson ID from URL parameters, validates request body against ReorderExercisesSchema, delegates exercise reordering to the service layer, and returns a standardized API response with HTTP 200 status indicating successful reordering operation.
Express request object containing lessonId in params and exercise_ids array in body
Express response object for sending HTTP response
Express next function for error handling middleware
Resolves when response is sent or error is passed to middleware
Reorders lessons within a module by updating their position sequence.
Extracts module ID from URL parameters, validates request body against ReorderLessonsSchema, delegates lesson reordering to the service layer, and returns a standardized API response with HTTP 200 status indicating successful reordering operation.
Express request object containing moduleId in params and lesson_ids array in body
Express response object for sending HTTP response
Express next function for error handling middleware
Resolves when response is sent or error is passed to middleware
HTTP controller class for comprehensive lesson management operations within the WayrApp content system.
Provides RESTful API endpoints for lesson CRUD operations, exercise assignment management, and maintains proper HTTP response formatting with comprehensive error handling. Integrates with Express middleware for authentication, validation, and error propagation.