Skip to content

feat(vaults): Add cursor-based pagination to getPublicVaults (#635)#587

Merged
vic-Gray merged 2 commits into
code-flexing:mainfrom
TochukwuJustice:cursor-based
Jun 23, 2026
Merged

feat(vaults): Add cursor-based pagination to getPublicVaults (#635)#587
vic-Gray merged 2 commits into
code-flexing:mainfrom
TochukwuJustice:cursor-based

Conversation

@TochukwuJustice

Copy link
Copy Markdown
Contributor

closes #370

Summary of Changes

  • DTOs: Introduced PaginationQueryDto with class validation for skip, limit, and cursor parameters. Added PaginatedVaultsResponseDto to encapsulate the list response.
  • Service Optimization: Upgraded getPublicVaults inside vaults.service.ts to utilize O(1) keyset pagination (relying on createdAt indexes) using TypeORM's LessThan() operator instead of relying purely on heavy SQL offsets.
  • Lookahead Logic: Implemented the limit + 1 query pattern to resolve the hasMore boolean in a single flat query without needing an expensive secondary count subquery.
  • Testing: Updated vaults.integration.spec.ts expectations to assert against the .data, .total, and .hasMore envelope format.
  • Bugfix: Fixed a pre-existing TypeScript import error for NotificationType inside vaults.service.ts.

Reason for the Changes

Addresses Issue #635. As the number of public vaults continues to grow, fetching an unpaginated array leads to network timeouts, high memory pressure on the Node.js server, and heavy database load. Returning a strict { data, total, hasMore } envelope solves this gracefully while ensuring future frontend clients can continuously scroll through the results using the cursor.

…exing#635)

- Created PaginationQueryDto to handle skip, limit, and cursor inputs.

- Added PaginatedVaultsResponseDto envelope {data, total, hasMore}.

- Implemented highly optimized keyset lookahead (limit + 1) pagination in vaults.service.ts.

- Updated integration tests and controller Swagger docs.

- fix: resolved missing NotificationType import in vaults.service.ts
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

@TochukwuJustice is attempting to deploy a commit to the vic's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 23, 2026

Copy link
Copy Markdown

@TochukwuJustice 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

@vic-Gray
vic-Gray merged commit 06f80be into code-flexing:main Jun 23, 2026
9 of 10 checks 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.

#635 Add cursor-based pagination to getPublicVaults

2 participants