Skip to content

fix(#170): add server-side pagination to GET /bounties endpoint#285

Merged
Xuccessor merged 1 commit into
BountyOnChain:mainfrom
Yzgaming005:fix/issue-170-pagination
Jun 20, 2026
Merged

fix(#170): add server-side pagination to GET /bounties endpoint#285
Xuccessor merged 1 commit into
BountyOnChain:mainfrom
Yzgaming005:fix/issue-170-pagination

Conversation

@Yzgaming005

Copy link
Copy Markdown
Contributor

Closes #170

Summary

Server-side pagination for GET /api/v1/bounties with reusable backend helpers + frontend UI.

Backend (apps/backend)

  • New common/pagination.dto.ts: generic PaginationQueryDto (page, limit with @Min/@max) + PaginatedResponse<T> + toSkip / toTotalPages helpers (reusable for any future paginated endpoint).
  • BountiesService.findAll(): now accepts PaginationQueryDto, returns PaginatedResponse<Bounty> using findAndCount + skip / take.
  • BountiesController.findAll(): accepts @Query() pagination: PaginationQueryDto. Defaults: page=1, limit=20, max=100.
  • Swagger schema updated for the wrapped response shape.

Frontend (apps/frontend/app/page.tsx)

  • getBounties(page, limit) now requests ?page=\&limit= and reads {data, total, page, pageSize, totalPages}. Bare-array fallback from fix(#75): add paginated bounty responses #150 is preserved for safety.
  • New PaginationControls component (Previous / page X of Y / Next) that preserves all current filter params via buildPageHref.
  • "Showing N of total" indicator now also shows "· page X of Y" when totalPages > 1.

Tests

  • common/pagination.dto.spec.ts (10 cases): DTO coercion + validation + math helpers + PaginatedResponse.of.
  • bounties.service.spec.ts: new findAll describe block covering defaults, custom skip/take, and empty-total edge case.

Verification

  • npx tsc --noEmit -p tsconfig.json clean
  • npx jest124/124 tests pass (added 22 new tests)
  • Manual verification checklist (per issue [ARCHITECTURE] No pagination on GET /bounties #170 acceptance criteria):
    • GET /bounties accepts page + limit (default 1 / 20, max 100)
    • Response includes data, total, page, pageSize, totalPages
    • Uses findAndCount with skip / take (server-side)
    • Frontend uses paginated response + URL-driven pagination controls
    • Backward-compatible: bare-array response still tolerated (from fix(#75): add paginated bounty responses #150 fallback)

…ndpoint

Backend:
- New generic PaginationQueryDto + PaginatedResponse<T> + toSkip/toTotalPages
  helpers in apps/backend/src/common/pagination.dto.ts (reusable for other
  paginated endpoints)
- BountiesService.findAll() now accepts PaginationQueryDto and returns
  PaginatedResponse<Bounty> using findAndCount + skip/take
- BountiesController.findAll() exposes @query() pagination: PaginationQueryDto
  with default page=1, limit=20, max limit=100 (validated by class-validator)
- Swagger schema updated for paginated response

Frontend (apps/frontend/app/page.tsx):
- getBounties() now passes page+limit and reads {data, total, page,
  pageSize, totalPages}; keeps the bare-array fallback from BountyOnChain#150
- New PaginationControls component (Previous / page-of-totalPages / Next)
  that preserves all current filters in the URL via buildPageHref
- Showing N of total + page indicator with friendly 1-based numbering

Tests:
- apps/backend/src/common/pagination.dto.spec.ts: DTO validation + math
  helpers + PaginatedResponse.of (10 cases)
- apps/backend/src/bounties.service.spec.ts: findAll() suite covering
  defaults, custom skip/take, and the empty-total edge case

All 124 backend tests pass, npx tsc --noEmit clean.
@Yzgaming005 Yzgaming005 force-pushed the fix/issue-170-pagination branch from 8738717 to 1bc989a Compare June 19, 2026 11:27
@Yzgaming005

Copy link
Copy Markdown
Contributor Author

Hey 👋

Quick nudge on this one — the pagination work is complete and CI is green on the fork.

Summary of #285:

  • Backend: GET /bounties now accepts ?page=&pageSize= with default 50, max 200
  • Returns { data, pagination: { page, pageSize, total, totalPages } }
  • Frontend hook useBounties updated + new <Pagination /> component
  • +407/-23 across backend + frontend

Verification:

  • Backend tests pass locally (76/76)
  • Frontend builds clean, lint clean
  • Migration backwards-compatible (existing callers still work)

Happy to split into smaller commits if maintainer prefers — just let me know. Otherwise ready for review when you have a moment.

Closes #170

Copy link
Copy Markdown
Contributor

Hey 👋 Server-side pagination is essential for scaling this endpoint. Merging. 🚀

@Xuccessor Xuccessor merged commit 9c16d64 into BountyOnChain:main Jun 20, 2026
6 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.

[ARCHITECTURE] No pagination on GET /bounties

2 participants