feat: add GET /api/v1/courses/:id/prerequisites endpoint - #445
Merged
DeFiVC merged 2 commits intoAug 31, 2026
Conversation
…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
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-configurablejsonbarray of course IDs (migration0020_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 —nullfor an anonymous caller, a real boolean (enrolled +completedAtset) for an authenticated one.GET /:id/prerequisiteswithoptionalAuth, mirroring the existingGET /:idcourse-detail route's auth pattern.course.routes.ts: thePOST /enroll/batchroute 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