feat: introduce Joi validation schemas and integrate them across various controllers for categories, lessons, courses, chapters, announcements, and admin course approvals.
This commit is contained in:
parent
c5aa195b13
commit
b56f604890
14 changed files with 553 additions and 28 deletions
|
|
@ -16,6 +16,7 @@ import {
|
|||
GetQuizAttemptsResponse,
|
||||
} from '../types/CoursesStudent.types';
|
||||
import { EnrollmentStatus } from '@prisma/client';
|
||||
import { SaveVideoProgressValidator, SubmitQuizValidator } from '../validators/CoursesStudent.validator';
|
||||
|
||||
@Route('api/students')
|
||||
@Tags('CoursesStudent')
|
||||
|
|
@ -149,9 +150,11 @@ export class CoursesStudentController {
|
|||
@Body() body: SaveVideoProgressBody
|
||||
): Promise<SaveVideoProgressResponse> {
|
||||
const token = request.headers.authorization?.replace('Bearer ', '');
|
||||
if (!token) {
|
||||
throw new ValidationError('No token provided');
|
||||
}
|
||||
if (!token) throw new ValidationError('No token provided');
|
||||
|
||||
const { error } = SaveVideoProgressValidator.validate(body);
|
||||
if (error) throw new ValidationError(error.details[0].message);
|
||||
|
||||
return await this.service.saveVideoProgress({
|
||||
token,
|
||||
lesson_id: lessonId,
|
||||
|
|
@ -225,9 +228,11 @@ export class CoursesStudentController {
|
|||
@Body() body: SubmitQuizBody
|
||||
): Promise<SubmitQuizResponse> {
|
||||
const token = request.headers.authorization?.replace('Bearer ', '');
|
||||
if (!token) {
|
||||
throw new ValidationError('No token provided');
|
||||
}
|
||||
if (!token) throw new ValidationError('No token provided');
|
||||
|
||||
const { error } = SubmitQuizValidator.validate(body);
|
||||
if (error) throw new ValidationError(error.details[0].message);
|
||||
|
||||
return await this.service.submitQuiz({
|
||||
token,
|
||||
course_id: courseId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue