Express routing configuration for lesson management and lesson-exercise assignment
operations within the WayrApp content management system.
This module provides REST API route definitions for managing lessons within the hierarchical
content structure (Course → Level → Section → Module → Lesson) and handling the many-to-many
relationship between lessons and exercises. The routes support full CRUD operations for lessons
nested under modules, as well as specialized endpoints for assigning, unassigning, and
reordering exercises within lessons.
The module implements a factory function pattern that accepts a PrismaClient instance and
returns a configured Express router with all lesson-related endpoints. This design supports
dependency injection and enables clean separation between route configuration and business logic.
All routes include comprehensive input validation using Zod schemas, role-based authentication
middleware, and standardized error handling.
Key architectural features include hierarchical lesson management within modules, many-to-many
lesson-exercise relationship management with ordering support, comprehensive input validation
and authentication middleware, role-based access control (admin for deletion, content_creator
for management), and standardized API response formatting with proper HTTP status codes.
The routes are mounted at the API base path in the main application and integrate with the
LessonController for business logic execution. This module serves as a critical component of
the content management system, enabling content creators and administrators to structure
learning materials effectively within the platform's educational hierarchy.
Author
Exequiel Trujillo
Since
1.0.0
Example
// Mount lesson routes in main application import { createLessonRoutes } from'@/modules/content/routes/lessonRoutes'; import { prisma } from'@/shared/database/connection';
// Available lesson management endpoints: // GET /api/v1/modules/:moduleId/lessons - List lessons in module // POST /api/v1/modules/:moduleId/lessons - Create lesson (content_creator/admin) // GET /api/v1/modules/:moduleId/lessons/:id - Get lesson by ID // PUT /api/v1/modules/:moduleId/lessons/:id - Update lesson (content_creator/admin) // DELETE /api/v1/modules/:moduleId/lessons/:id - Delete lesson (admin only)
Example
// Available lesson-exercise assignment endpoints: // GET /api/v1/lessons/:lessonId/exercises - Get lesson exercises // POST /api/v1/lessons/:lessonId/exercises - Assign exercise to lesson // DELETE /api/v1/lessons/:lessonId/exercises/:exerciseId - Unassign exercise // PUT /api/v1/lessons/:lessonId/exercises/reorder - Reorder exercises
Express routing configuration for lesson management and lesson-exercise assignment operations within the WayrApp content management system.
This module provides REST API route definitions for managing lessons within the hierarchical content structure (Course → Level → Section → Module → Lesson) and handling the many-to-many relationship between lessons and exercises. The routes support full CRUD operations for lessons nested under modules, as well as specialized endpoints for assigning, unassigning, and reordering exercises within lessons.
The module implements a factory function pattern that accepts a PrismaClient instance and returns a configured Express router with all lesson-related endpoints. This design supports dependency injection and enables clean separation between route configuration and business logic. All routes include comprehensive input validation using Zod schemas, role-based authentication middleware, and standardized error handling.
Key architectural features include hierarchical lesson management within modules, many-to-many lesson-exercise relationship management with ordering support, comprehensive input validation and authentication middleware, role-based access control (admin for deletion, content_creator for management), and standardized API response formatting with proper HTTP status codes.
The routes are mounted at the API base path in the main application and integrate with the LessonController for business logic execution. This module serves as a critical component of the content management system, enabling content creators and administrators to structure learning materials effectively within the platform's educational hierarchy.
Author
Exequiel Trujillo
Since
1.0.0
Example
Example
Example