fix: paginate GET /chat (limit + before cursor)#110
Open
bmersereau wants to merge 3 commits into
Open
Conversation
Adds `limit` (default 50, max 200) and `before` (ISO timestamp cursor) query parameters to prevent unbounded chat list queries for active users.
bmersereau
commented
May 13, 2026
Author
bmersereau
left a comment
There was a problem hiding this comment.
PR Review
Summary
Adds cursor-based pagination (limit + before ISO timestamp) to GET /chat. Implementation is correct and backward-compatible — callers with no params get 50 chats. The limit cap at 200 is reasonable. Two static-analysis tests verify the limit and cursor are present.
Findings
- [severity:praise]
beforecursor validated withNumber.isNaN(new Date(...).getTime())— correctly rejects non-ISO strings while accepting valid timestamps - [severity:nit] The
beforecursor is applied after the.limit()call, meaning Supabase will applylt("created_at", before)as a WHERE clause andlimitas LIMIT — correct behavior, but a comment clarifying cursor-vs-offset semantics would help future readers - [severity:minor] Static tests use
readFileSyncon the source file; they verify the pattern is present but don't test the actual endpoint behavior (e.g., correct rows returned). Acceptable for now, but a true integration test would give higher confidence
Specific checks
-
"test": "vitest run"in package.json ✓ - Tests pass: 2/2 ✓
-
tsconfig.jsonexcludes__tests__from tsc build ✓
Verdict
Approve with nits — ship 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
limit(default 50, max 200) andbefore(ISO timestamp cursor) query parameters toGET /chatCloses #105
Closes #114
Changes
backend/src/routes/chat.ts— limit + before-cursor pagination on the chat list querybackend/src/lib/__tests__/chatPagination.test.ts— static analysis tests verifying pagination is presentbackend/tsconfig.json— exclude__tests__dirs from the main tsc build (tests use vitest directly)backend/package.json—"test": "vitest run"script addedTest plan
npx vitest run)npx tsc --noEmit)