Skip to content

refactor(webhooks): extract shared offset-pagination helper - #420

Merged
mikewheeleer merged 1 commit into
Agentpay-Org:mainfrom
thlpkee20-wq:refactor/webhooks-01-validation-helper
Jul 28, 2026
Merged

refactor(webhooks): extract shared offset-pagination helper#420
mikewheeleer merged 1 commit into
Agentpay-Org:mainfrom
thlpkee20-wq:refactor/webhooks-01-validation-helper

Conversation

@thlpkee20-wq

Copy link
Copy Markdown
Contributor

Closes #381

GET /api/v1/webhooks inlined the same limit/offset parsing and
slicing preamble duplicated in the api-keys list handler. Extracted it
into applyOffsetPage() in src/listPagination.ts as a single reusable
entry point consumed by the webhooks handler. Pure refactor — same
defaults (limit defaults to the full result set, offset defaults to
0), same response shape ({ items, total }).

Note: src/routes/apiKeys.ts in the actual merged history already
introduces this same helper independently (api-keys PR #410) since both
were built in parallel; whichever merges second will need a small
rebase to avoid a duplicate listPagination.ts, but the two
implementations are identical so it's a no-op resolve.

Test plan

  • npm run build
  • npm run lint
  • npm test — targeted run of list-pagination.test.js,
    apikeys-webhooks.test.js, webhook-event-validation.test.js,
    webhook-get-one.test.js, webhook-validator.test.js,
    routes/operational.test.js: 36/36 passing, no behavior change.

The GET /api/v1/webhooks handler inlined the same limit/offset parsing
and slicing preamble duplicated in the api-keys list handler. Extracted
it into applyOffsetPage() in src/listPagination.ts as a single reusable
entry point; behavior is unchanged (same defaults, same response shape).
@mikewheeleer

Copy link
Copy Markdown
Contributor

looks good @thlpkee20-wq — well scoped and easy to review. merging 👍

@mikewheeleer
mikewheeleer merged commit 867b725 into Agentpay-Org:main Jul 28, 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.

Extract the shared webhooks handler validation into a reusable helper

2 participants