Initializes the ExerciseController with required service dependencies.
Prisma database client for service layer initialization
Creates a new exercise with comprehensive validation and type-specific data verification.
Validates request body against CreateExerciseSchema, performs exercise type conversion for internal consistency (dash-to-underscore normalization), delegates exercise creation to the service layer, and returns a standardized API response with HTTP 201 status on successful creation.
Express request object containing exercise 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 exercise by its unique identifier with comprehensive validation.
Extracts exercise 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 exercise data with type-specific information.
Express request object containing exercise 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 exercises across all types with comprehensive query support.
Processes query parameters for pagination, sorting, and filtering options, delegates exercise retrieval to the service layer, and returns a standardized API response with HTTP 200 status. Includes pagination metadata in response headers for client consumption and supports filtering by exercise type through query parameters.
Express request object containing query parameters for pagination and filtering
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
Retrieves paginated exercises filtered by a specific exercise type with query support.
Extracts exercise type from URL parameters, validates parameter presence, processes query parameters for pagination and sorting, delegates type-specific exercise 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 exercise type 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 exercise with partial data and comprehensive validation.
Extracts exercise ID from URL parameters, validates request body against UpdateExerciseSchema, performs exercise type conversion for internal consistency when type is updated, delegates exercise update to the service layer, and returns a standardized API response with HTTP 200 status containing updated exercise data.
Express request object containing exercise 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 an exercise and removes it from all lesson assignments.
Extracts exercise ID from URL parameters, validates parameter presence, delegates exercise deletion to the service layer, and returns a standardized API response with HTTP 204 status indicating successful deletion without content. This operation may cascade to remove exercise assignments from lessons.
Express request object containing exercise 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
HTTP controller class for comprehensive exercise management operations within the WayrApp content system.
Provides RESTful API endpoints for exercise CRUD operations across all supported exercise types, maintains proper HTTP response formatting with comprehensive error handling, and integrates with Express middleware for authentication, validation, and error propagation.