Skip to content

Implement Cursor-Based Pagination for All List Endpoints #1167

Description

@miss-yusrah

Labels: backend feature 200pts

Background:
Most list endpoints use offset-based pagination which is broken for real-time data (items inserted between pages cause duplicates/skips). Cursor-based pagination is stable.

Problem:
GET /api/v1/proposals, GET /api/v1/audit, GET /api/v1/transactions use ?page=N&limit=M pagination. During active event ingestion, page 2 can duplicate items from page 1.

What "Done" Looks Like:

  • Replace page/offset pagination with cursor/limit on all list endpoints
  • Cursor = opaque base64-encoded object containing: { last_id, last_ledger, direction }
  • Response includes next_cursor and has_more fields
  • Backward pagination: cursor can encode direction: 'prev' for reverse traversal
  • Existing page/offset params still accepted but deprecated (log warning, redirect to cursor)
  • Tests: forward pagination, backward pagination, cursor stability during new inserts

Key Files:

  • backend/src/modules/proposals/proposals.controller.ts
  • backend/src/modules/audit/audit.controller.ts
  • backend/src/modules/transactions/transactions.controller.ts
  • backend/src/shared/ — new pagination.ts cursor utilities

Constraints:

  • Cursor is opaque to client (base64, not guessable)
  • Invalid cursor returns 400 with helpful error
  • Default limit 20, max 100

PR Must Include:

  • pagination.ts cursor utilities
  • Cursor pagination on all 3 list endpoints
  • Backward pagination
  • Deprecation warning for old params
  • Tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions