feat: Add k6 video watching load test and remove optional comment body from admin course approval.
This commit is contained in:
parent
743d3b8c2f
commit
c118e5c3dc
3 changed files with 271 additions and 15 deletions
|
|
@ -1,11 +1,10 @@
|
|||
import { Body, Get, Path, Post, Request, Response, Route, Security, SuccessResponse, Tags } from 'tsoa';
|
||||
import { ValidationError } from '../middleware/errorHandler';
|
||||
import { AdminCourseApprovalService } from '../services/AdminCourseApproval.service';
|
||||
import { ApproveCourseValidator, RejectCourseValidator } from '../validators/AdminCourseApproval.validator';
|
||||
import { RejectCourseValidator } from '../validators/AdminCourseApproval.validator';
|
||||
import {
|
||||
ListPendingCoursesResponse,
|
||||
GetCourseDetailForAdminResponse,
|
||||
ApproveCourseBody,
|
||||
ApproveCourseResponse,
|
||||
RejectCourseBody,
|
||||
RejectCourseResponse,
|
||||
|
|
@ -61,19 +60,12 @@ export class AdminCourseApprovalController {
|
|||
@Response('404', 'Course not found')
|
||||
public async approveCourse(
|
||||
@Request() request: any,
|
||||
@Path() courseId: number,
|
||||
@Body() body?: ApproveCourseBody
|
||||
@Path() courseId: number
|
||||
): Promise<ApproveCourseResponse> {
|
||||
const token = request.headers.authorization?.replace('Bearer ', '');
|
||||
if (!token) throw new ValidationError('No token provided');
|
||||
|
||||
// Validate body if provided
|
||||
if (body) {
|
||||
const { error } = ApproveCourseValidator.validate(body);
|
||||
if (error) throw new ValidationError(error.details[0].message);
|
||||
}
|
||||
|
||||
return await AdminCourseApprovalService.approveCourse(token, courseId, body?.comment);
|
||||
return await AdminCourseApprovalService.approveCourse(token, courseId, undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue