Skip to content

Comments

fix: pagination service, common imports, and build errors#178

Open
Jayrodri088 wants to merge 1 commit intoNexacore-Org:mainfrom
Jayrodri088:feat-pagination-service
Open

fix: pagination service, common imports, and build errors#178
Jayrodri088 wants to merge 1 commit intoNexacore-Org:mainfrom
Jayrodri088:feat-pagination-service

Conversation

@Jayrodri088
Copy link
Contributor

Summary

Fixes pagination for courses/lessons and resolves backend build errors (wrong imports, missing entity, and dependency/type issues).

Changes

Pagination

  • PaginationService (common/services/pagination.service.ts): Implement generic paginate<T>(repository, options, findOptions?) using TypeORM findAndCount, returning { data, total, page, limit, totalPages }.
  • PaginationDto (common/dto/pagination.dto.ts): Add query DTO with page (default 1, min 1) and limit (default 10, min 1, max 100), using @Type(() => Number) and class-validator.
  • CommonModule: New global module that provides and exports PaginationService; registered in AppModule.
  • Courses: GET /courses now accepts ?page=&limit= and returns paginated payload via findAllPaginated; removed duplicate commented GET handler; controller no longer injects PaginationService (used in service).
  • Lessons: GET /lessons and GET /lessons/course/:courseId accept ?page=&limit= and return paginated results via findAllPaginated and findAllByCoursePaginated.

Build / codebase fixes

  • Imports: Correct paths for User and UserRole (e.g. ../../users/entities/user.entity), Lesson (e.g. ../../lessons/entities/lesson.entity or ./entities/lesson.entity), and UserService (../../users/users.service) in auth, common, courses, lessons, quizzes, and rewards.
  • @nestjs/mapped-types: Version set to ^2.0.2 in package.json so PartialType resolves and Update DTOs type-check.
  • Progress entity: Replace empty stub with TypeORM entity (id, completed, user/userId, lesson/lessonId) so ProgressService compiles and runs.
  • Quizzes: Add QuestionType import from ../entities/question.entity in quiz-response.dto.ts.
  • Certificates: Use UserRole.ADMIN instead of 'admin' in @Roles() for admin-only routes.

Testing

  • npm run build passes (exit code 0).
  • GET /courses and GET /lessons (and GET /lessons/course/:courseId) support ?page=1&limit=10 and return paginated responses without runtime errors.

Closes: #156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement PaginationService and Remove the Empty Misspelled Duplicate

1 participant