Skip to content

refactor: split course controller into feature controllers - #2386

Open
its-gabo wants to merge 1 commit into
stagingfrom
gs_refactor_split_large_api_files
Open

its-gabo wants to merge 1 commit into
stagingfrom
gs_refactor_split_large_api_files

Conversation

@its-gabo

@its-gabo its-gabo commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Overview

src/courses/course.controller.ts had grown to 1,471 lines and 53 endpoints covering every course feature. This PR moves the endpoints into controllers that live next to the feature folders that already hold their services. CourseController keeps only the core course endpoints: reading, creating and updating a course, its media, trailer, certificate flag, settings and lesson sequence.

Controller Endpoints
catalog/course-catalog.controller.ts all, published-lookup, get-student-courses, available-courses, available-categories, top-courses, content-creator-courses
dashboard/course-learner-dashboard.controller.ts dashboard-summary, :courseId/open, :courseId/repeat
enrollment/course-enrollment.controller.ts :courseId/students, enroll-course, enroll-courses, enroll-groups-to-course, unenroll-groups-from-course, unenroll-course
authoring/course-bulk-editing.controller.ts bulk/status, bulk/archive, bulk/category
authoring/course-deletion.controller.ts deleteCourse, deleteManyCourses
duplication/course-duplication.controller.ts :courseId/duplicate, duplication-jobs
learning-mode/course-student-mode.controller.ts :courseId/student-mode
statistics/course-statistics.controller.ts the seven :courseId/statistics/* endpoints
languages/course-translation.controller.ts beta-course-missing-translations, beta-create-language, language, generate-translations
scorm-export/course-scorm-export.controller.ts :courseId/scorm-export
ownership/course-ownership.controller.ts course-ownership/transfer, course-ownership/:courseId
master-course/master-course.controller.ts master export, exports, export-candidates, export-jobs

What stays the same:

  • Routes: every route keeps its path under /api/course.
  • Endpoint code: permissions, @Validate schemas, guards, pipes and handler bodies are moved unchanged.
  • Generated client: moved endpoints pin their original operationId (@ApiOperation({ operationId: "CourseController_<method>" })). The Swagger schema and generated-api.ts method names stay the same, so apps/web needs no changes.

Tests added before the move, for the two endpoints that had no HTTP-level test:

  • POST /api/course/:courseId/repeat: starts a repetition for a learner who completed the course, and answers 400 courseRepetition.errors.unavailable otherwise.
  • GET /api/course/:courseId/statistics/learning-time-filter-options: a group manager is offered only the groups they manage; an admin is offered every group with learners in the course.

Business Value

No user-facing change. Course endpoints become easier to find and review, and changes to different course features stop conflicting in one 1,500-line file.

PR flow video

Video skipped for 8629abcefea9.

This PR only splits the course controller into feature controllers and adds tests; routes, handlers and generated client names are unchanged, so nothing new is visible in the browser.

@its-gabo
its-gabo requested a review from Japrolol December 4, 2026 16:08
@its-gabo its-gabo self-assigned this Dec 4, 2026
@its-gabo its-gabo added the review me 👀 PR is ready to be reviewed label Dec 4, 2026
@its-gabo
its-gabo marked this pull request as ready for review December 4, 2026 16:09

This branch has not been deployed

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

Labels

review me 👀 PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant