fix(backend): add cursor pagination to enrollment and queue list endpoints - #231
Open
jajafwangshak86-ops wants to merge 1 commit into
Conversation
…oints (Stellar-Deejah#182) - Add backend/src/utils/pagination.ts with paginate() helper using SDK's encodeCursor/decodeCursor for the canonical 0:index cursor format - Update GET /api/enrollments/:identity to accept limit/cursor params and return { items, nextCursor, total } envelope (default limit 50, max 200) - Update GET /api/enrollments/queue/:queueId with same pagination contract - Update GET /api/queues with limit/cursor/status query support - Fix stale test assertions in enrollments.route.test.ts and queues.route.test.ts to expect paginated envelope and correct encodeCursor(0,N) cursor values - Add multi-page traversal tests for both enrollment list endpoints - Update docs/api-reference/enrollments.md and queues.md with pagination schema Closes Stellar-Deejah#182
|
@jajafwangshak86-ops is attempting to deploy a commit to the Deejah Team on Vercel. A member of the Team first needs to authorize it. |
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
Closes #182
Adds cursor-based pagination to the three unbounded list endpoints identified in the issue, preventing multi-MB responses on busy deployments.
Changes
New file:
backend/src/utils/pagination.tspaginate<T>(items, opts)helper that slices an array bylimit+ cursor offsetencodeCursor/decodeCursor(format:base64("0:index")) so cursor semantics are shared across the stackValidationError(→ 400)backend/src/routes/enrollments.tsGET /api/enrollments/:identity— accepts?limitand?cursor, returns{ items, nextCursor, total }GET /api/enrollments/queue/:queueId— same pagination contractbackend/src/routes/queues.tsGET /api/queues— accepts?limit,?cursor, and existing?statusfilter; returns{ items, nextCursor, total }Before / After response shapes
Before (unbounded):
After (paginated):
Backward compatibility
Omitting
limitandcursorreturns the first 50 items in the paginated envelope — callers that previously iterated a bare array will need to read.items, but no params → no breakage at the transport level.Tests
enrollments.route.test.tsthat expected bare arraysqueues.route.test.tscursor values to use the correctencodeCursor(0, N)format and error shape (res.body.error.message)Docs
docs/api-reference/enrollments.md— updated response schema with pagination envelope and query param tabledocs/api-reference/queues.md— updated to show paginated envelope and full query param table