Skip to content

feat(prompts): add cursor-based pagination to GET /api/prompts - #255

Open
ZacLou wants to merge 1 commit into
Prompt-Hash-Stellar:mainfrom
ZacLou:fix/243-cursor-pagination
Open

feat(prompts): add cursor-based pagination to GET /api/prompts#255
ZacLou wants to merge 1 commit into
Prompt-Hash-Stellar:mainfrom
ZacLou:fix/243-cursor-pagination

Conversation

@ZacLou

@ZacLou ZacLou commented Sep 14, 2026

Copy link
Copy Markdown

Summary

Implements stable cursor-based pagination for GET /api/prompts, replacing the previous full-collection fetch that returned all published prompts at once.

Changes

  • Base64url cursor encoding/decoding with validation
  • Cursor uses createdAt + _id tuple for stable sort order
  • Limit validation (1–100, default 20)
  • Fetch limit + 1 to determine hasNextPage without extra count query
  • Return shape changed from Prompt[] to { prompts, nextCursor }

Testing

  • 11 new unit tests in api/prompts/index.test.ts
  • Covers: invalid cursor, empty results, exact page boundary, hasNextPage true/false, limit clamping, missing owner

Closes #243

Implements stable cursor pagination using createdAt+_id tuple,
replacing the previous full-collection fetch. Includes base64url
cursor encoding/decoding, limit validation (1-100), and 11
edge-case tests covering invalid cursors, empty results, and
hasNextPage boundary.

Closes Prompt-Hash-Stellar#243
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prompt marketplace search should use stable cursor pagination under listing churn

1 participant