Skip to content

feat(api-keys): add opaque-cursor pagination to the listing endpoint - #411

Merged
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
thlpkee20-wq:feature/api-keys-01-pagination
Jul 29, 2026
Merged

feat(api-keys): add opaque-cursor pagination to the listing endpoint#411
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
thlpkee20-wq:feature/api-keys-01-pagination

Conversation

@thlpkee20-wq

Copy link
Copy Markdown
Contributor

Closes #382

Adds a generic paginateByCursor() helper (src/cursorPagination.ts)
and an applyListPage() wrapper that layers opt-in ?cursor= paging on
top of the existing offset/limit contract on GET /api/v1/api-keys:
passing cursor takes priority over offset, and both modes now report
a stable nextCursor so existing offset-based clients can migrate
without a contract change. A malformed or expired cursor returns 400 invalid_request. Item shape is unchanged.

Test plan

  • npm run build
  • npm run lint
  • npm test — targeted run of list-pagination.test.js,
    apikey-recognition.test.js, routes/operational.test.js: 13/13
    passing.

Note

I don't have push access to this repo (fork-only), so I can't target a
non-main base branch for a true stacked PR. This branch is stacked on
#410 (refactor(api-keys): extract shared offset-pagination helper) —
until that merges, this diff will include its commit too. The
cursor-pagination-specific change is src/cursorPagination.ts (new) plus
the applyListPage addition in src/listPagination.ts and the updated
GET /api/v1/api-keys handler in src/routes/apiKeys.ts.

The GET /api/v1/api-keys handler inlined the same limit/offset parsing
and slicing preamble duplicated in the webhooks list handler. Extracted
it into applyOffsetPage() in src/listPagination.ts as a single reusable
entry point; behavior is unchanged (same defaults, same response shape).
Adds a generic paginateByCursor() helper (src/cursorPagination.ts) and
an applyListPage() wrapper that layers opt-in ?cursor= paging on top of
the existing offset/limit contract: passing cursor takes priority over
offset, and both modes now report a stable nextCursor so existing
offset-based clients can migrate without a contract change. Malformed
or expired cursors return 400 invalid_request. Item shape and existing
offset behavior are unchanged.
@mikewheeleer

Copy link
Copy Markdown
Contributor

@thlpkee20-wq clean implementation, merging with thanks 🙌

1 similar comment
@mikewheeleer

Copy link
Copy Markdown
Contributor

@thlpkee20-wq clean implementation, merging with thanks 🙌

@mikewheeleer
mikewheeleer merged commit b33313f into Agentpay-Org:main Jul 29, 2026
1 check 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

Development

Successfully merging this pull request may close these issues.

Add cursor pagination to the api-keys listing endpoint

2 participants