Skip to content

Commit

Permalink
fix: merge main into lc-490
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszszczecina committed Dec 19, 2024
2 parents 303255b + bddeae7 commit 8cd2aed
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
8 changes: 6 additions & 2 deletions apps/api/src/courses/course.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ import { SortCourseFieldsOptions } from "src/courses/schemas/courseQuery";
import { CreateCourseBody, createCourseSchema } from "src/courses/schemas/createCourse.schema";
import { commonShowCourseSchema } from "src/courses/schemas/showCourseCommon.schema";
import { UpdateCourseBody, updateCourseSchema } from "src/courses/schemas/updateCourse.schema";
import { allCoursesValidation, coursesValidation } from "src/courses/validations/validations";
import {
allCoursesValidation,
coursesValidation,
studentCoursesValidation,
} from "src/courses/validations/validations";
import { USER_ROLES, UserRole } from "src/user/schemas/userRoles";

import type {
Expand Down Expand Up @@ -90,7 +94,7 @@ export class CourseController {
}

@Get("get-student-courses")
@Validate(coursesValidation)
@Validate(studentCoursesValidation)
async getStudentCourses(
@Query("title") title: string,
@Query("category") category: string,
Expand Down
26 changes: 26 additions & 0 deletions apps/api/src/courses/validations/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,32 @@ export const allCoursesValidation = {
],
};

export const studentCoursesValidation = {
response: paginatedResponse(allCoursesSchema),
request: [
{ type: "query" as const, name: "title", schema: Type.String() },
{ type: "query" as const, name: "category", schema: Type.String() },
{ type: "query" as const, name: "author", schema: Type.String() },
{
type: "query" as const,
name: "creationDateRange[0]",
schema: Type.String(),
},
{
type: "query" as const,
name: "creationDateRange[1]",
schema: Type.String(),
},
{
type: "query" as const,
name: "page",
schema: Type.Number({ minimum: 1 }),
},
{ type: "query" as const, name: "perPage", schema: Type.Number() },
{ type: "query" as const, name: "sort", schema: sortCourseFieldsOptions },
],
};

export const coursesValidation = {
response: paginatedResponse(allCoursesSchema),
request: [
Expand Down
9 changes: 0 additions & 9 deletions apps/api/src/swagger/api-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1027,15 +1027,6 @@
"get": {
"operationId": "CourseController_getStudentCourses",
"parameters": [
{
"name": "excludeCourseId",
"required": false,
"in": "query",
"schema": {
"format": "uuid",
"type": "string"
}
},
{
"name": "title",
"required": false,
Expand Down

0 comments on commit 8cd2aed

Please sign in to comment.