Skip to content

refactor(api): standardize cursor-based pagination across list endpoi… - #669

Merged
Topmatrixmor2014 merged 1 commit into
FinChippay:mainfrom
Killerjunior:feat/issue-344-standardize-pagination
Aug 18, 2026
Merged

refactor(api): standardize cursor-based pagination across list endpoi…#669
Topmatrixmor2014 merged 1 commit into
FinChippay:mainfrom
Killerjunior:feat/issue-344-standardize-pagination

Conversation

@Killerjunior

Copy link
Copy Markdown
Contributor

refactor(api): standardize cursor-based pagination across list endpoints (#344)

Summary

Standardizes cursor-based pagination across every list endpoint in the backend with uniform request parameters (cursor, limit default 20, max 100) and canonical response shapes ({ data: [...], pagination: { nextCursor, hasMore, total } }).

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / chore
  • Smart contract change

Related issue

Closes #344

Changes

  • Pagination Utility & Formatter (backend/src/utils/paginate.js): Added formatPaginatedResponse(data, cursor, total, extra) to standardize the payload shape across in-memory and database-backed list queries while preserving RFC 5988 Link (rel="next") and X-Total-Count headers.
  • Pagination Middleware (backend/src/middleware/pagination.js & backend/src/server.js): Applied paginationMiddleware globally to sanitize limit (default 20, capped at 100) and parse opaque base64url cursor tokens across all routes.
  • Account & Payment Endpoints (accounts.js, payments.js, paymentController.js): Added GET /api/v1/accounts/:publicKey/payments and updated GET /api/v1/payments/:publicKey to return standard paginated envelopes using Horizon paging tokens as cursors.
  • Tips & Events Endpoints (tips.js, tipsController.js, events.js, eventController.js): Standardized GET /api/v1/tips/received/:creatorPublicKey, GET /api/v1/tips/sent/:senderPublicKey, GET /api/v1/tips/:creatorPublicKey, GET /api/v1/events/:publicKey, and GET /api/v1/events/:publicKey/:eventType.
  • Webhooks, Turrets & Scheduled Transactions (webhooks.js, turrets.js, turretsController.js, scheduledTransactions.js): Standardized GET /api/v1/webhooks/:publicKey, GET /api/v1/webhooks/:publicKey/events, GET /api/v1/turrets, GET /api/v1/turrets/:id/history, GET /api/v1/scheduled-transactions/:publicKey, and GET /api/v1/scheduled-transactions/:publicKey/pending.
  • API Documentation (docs/api.md): Added a dedicated "Pagination" section detailing parameters, response structures, header definitions, and all supported endpoints.
  • Test Suite (backend/__tests__/pagination.test.js): Added unit tests for formatPaginatedResponse and integration tests validating cursor pagination across all list endpoints.

Testing

  • Tested locally on Testnet
  • Added/updated unit tests
  • Manually tested UI flow

Screenshots (if UI change)

N/A (Backend API standardization)

Checklist

  • My code follows the project style
  • I've updated docs if needed
  • No console errors or warnings
  • I've rebased on latest main

@github-actions github-actions Bot added the needs-review PR ready for Greptile AI code review label Aug 17, 2026
@github-actions

Copy link
Copy Markdown

🤖 Greptile AI Code Review

Greptile will automatically review this PR (15 file(s) changed).

Review gates:

  • ✅ CodeQL Security Scan
  • ✅ Custom rules (.greptile/config.json)
  • ✅ Architecture guidelines (.greptile/rules.md)

To manually trigger a re-review, comment @greptileai on this PR.
To skip review, add the skip-review label.

@Topmatrixmor2014
Topmatrixmor2014 merged commit d8ea613 into FinChippay:main Aug 18, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review PR ready for Greptile AI code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[New] Server-Side Pagination Standardization Across All List Endpoints

2 participants