Skip to content

feat: add GET /api/v1/courses/:id/prerequisites endpoint - #445

Merged
DeFiVC merged 2 commits into
ChainLearnOfficial:mainfrom
Williams-1604:feat/course-prerequisites-endpoint-369-372-370-368
Aug 31, 2026
Merged

feat: add GET /api/v1/courses/:id/prerequisites endpoint#445
DeFiVC merged 2 commits into
ChainLearnOfficial:mainfrom
Williams-1604:feat/course-prerequisites-endpoint-369-372-370-368

Conversation

@Williams-1604

Copy link
Copy Markdown
Contributor

Summary

Adds GET /api/v1/courses/:id/prerequisites: returns a course's prerequisite courses with the caller's completion status per prerequisite.

Changes

  • courses.prerequisites: new admin-configurable jsonb array of course IDs (migration 0020_courses_prerequisites.sql). Informational only — enrolling in a course never checks whether its prerequisites are met.
  • courseService.getPrerequisites(courseId, userId): resolves the configured prerequisite IDs to course rows (preserving the configured order, not DB row order), and annotates each with completion status — null for an anonymous caller, a real boolean (enrolled + completedAt set) for an authenticated one.
  • New route GET /:id/prerequisites with optionalAuth, mirroring the existing GET /:id course-detail route's auth pattern.
  • Also fixes a pre-existing syntax bug in course.routes.ts: the POST /enroll/batch route registration was missing its closing );, silently folding the reviews/share route registrations that followed it into the same expression.

Tests

6 service-layer tests: not-found, empty prerequisite list, ordering, anonymous vs. authenticated completion status, and an in-progress-but-not-completed enrollment correctly not counting as completed.

Closes #369
Closes #372
Closes #370
Closes #368

…fficial#369)

- courses.prerequisites: new admin-configurable jsonb array of course
  IDs (migration 0020), informational only — enrolling never checks it.
- courseService.getPrerequisites(courseId, userId): resolves the
  configured prerequisite IDs to course rows, preserving configured
  order, and annotates each with the caller's completion status —
  null for an anonymous caller, boolean (enrolled + completedAt set)
  for an authenticated one.
- New route GET /:id/prerequisites (optionalAuth, mirrors GET /:id).
- Also fixes a pre-existing syntax bug in course.routes.ts: the
  POST /enroll/batch route registration was missing its closing
  `);`, silently swallowing the reviews/share routes that followed
  it into the same expression.
- 6 service-layer tests covering not-found, empty list, ordering,
  anonymous vs authenticated completion, and in-progress-but-not-
  completed enrollments.

Closes ChainLearnOfficial#369
Closes ChainLearnOfficial#372
Closes ChainLearnOfficial#370
Closes ChainLearnOfficial#368
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@Williams-1604 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@DeFiVC
DeFiVC merged commit 105b5b7 into ChainLearnOfficial:main Aug 31, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants