Skip to content

Chore/make streams list cursor paginated with #193

Merged
Jagadeeshftw merged 2 commits into
Fluxora-Org:mainfrom
abrak01:chore/make-streams-list-cursor-paginated-with-
Apr 23, 2026
Merged

Chore/make streams list cursor paginated with #193
Jagadeeshftw merged 2 commits into
Fluxora-Org:mainfrom
abrak01:chore/make-streams-list-cursor-paginated-with-

Conversation

@abrak01
Copy link
Copy Markdown
Contributor

@abrak01 abrak01 commented Apr 23, 2026

What

Replaces the implicit offset-based listing with keyset cursor pagination, adds
indexed filter params, and fixes pre-existing import and response-shape bugs that
were preventing the route from compiling.

Changes

src/routes/streams.ts

  • Add missing imports: parseBody, CreateStreamSchema, formatZodIssues,
    assertValidApiTransition, ApiStreamStatus
  • Fix all response shapes to flat JSON — tests expect response.body.streams
    directly, not a successResponse envelope
  • Fix normalizeCreateStreamInput to throw ApiError with the correct signature
  • Add status, sender, recipient filter query params to GET /api/streams

src/db/repositories/streamRepository.ts

  • Add findWithCursor(filter, limit, cursor?) — keyset pagination on id ASC
  • Fetches limit + 1 rows to detect hasMore without a separate COUNT query
  • Supports status, sender_address, recipient_address, contract_id filters (all
    backed by existing indexes)
  • Decimal-string amounts pass through TEXT columns untouched

openapi.yaml

  • Replace offset pagination with cursor pagination params (cursor, include_total)
  • Add status, sender, recipient filter params with enum/format constraints
  • Inline response schema: streams, has_more, next_cursor, total

docs/STREAMS.md

  • Replace offset pagination docs with cursor pagination model
  • Document all filter params and their backing indexes
  • Add two-page traversal example

Pagination model

Streams are ordered by id ASC. The cursor encodes the last seen id as a base64url
token. Each subsequent page fetches id > cursor, so results are stable even when
new streams are inserted between requests. total is a point-in-time snapshot, not
a cursor-consistent count.

Decimal-string guarantee

No numeric coercion occurs at any layer — amount fields are stored as TEXT and
returned as strings throughout.

closes #123

…dexed filters

- src/routes/streams.ts
  - Add missing imports: parseBody, CreateStreamSchema, formatZodIssues,
    assertValidApiTransition, ApiStreamStatus
  - Fix all response shapes to flat JSON (tests expect flat, not successResponse
    envelope)
  - Fix normalizeCreateStreamInput error handling to use ApiError correctly
  - Add status, sender, recipient filter query params to GET /api/streams

- src/db/repositories/streamRepository.ts
  - Add findWithCursor(filter, limit, cursor?) method
  - Keyset pagination: id > cursor with stable id ASC ordering
  - Fetches limit+1 rows to detect hasMore without a separate COUNT query
  - Supports status, sender_address, recipient_address, contract_id filters
  - Decimal-string amounts pass through TEXT columns untouched

- openapi.yaml
  - Replace offset pagination with cursor pagination params
  - Add status, sender, recipient filter params
  - Inline response schema with streams/has_more/next_cursor/total

- docs/STREAMS.md
  - Replace offset pagination docs with cursor pagination model
  - Document all filter params and their backing indexes
  - Add pagination example showing two-page traversal
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 23, 2026

@abrak01 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Jagadeeshftw Jagadeeshftw merged commit 81904c7 into Fluxora-Org:main Apr 23, 2026
1 check failed
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.

Make streams list cursor-paginated with stable ordering and indexed filters

2 participants