Skip to content

feat: added Pagination standard (cursor vs offset)#247

Merged
aji70 merged 3 commits intoMyFanss:mainfrom
okekefrancis112:pagination
Feb 25, 2026
Merged

feat: added Pagination standard (cursor vs offset)#247
aji70 merged 3 commits intoMyFanss:mainfrom
okekefrancis112:pagination

Conversation

@okekefrancis112
Copy link
Contributor

Summary

This PR standardizes all list/collection API endpoints across both myfans-backend/ and backend/ to use consistent offset/page-based pagination, resolving #217. A shared pagination infrastructure was introduced in myfans-backend/PaginationQueryDto (query params: page default 1, limit default 20) and a generic PaginatedResponseDto<T> (response shape: items, total, page, limit, total_pages) — along with stateless TypeORM helpers (paginate() for QueryBuilder, createPaginatedResponse() for .findAndCount() results). Six existing modules (creators, posts, comments, messages, earnings, subscriptions) were refactored to extend the shared base DTO and return the standardized response wrapper, eliminating per-module duplication of pagination logic. A new GET /subscriptions list endpoint was added to myfans-backend/ with status filtering and creator relation loading. In backend/, the subscriptions service was updated from returning a plain array to a paginated response with a required fan query param. The earnings module was migrated from raw offset/limit to page-based pagination, with a coordinated frontend update in earnings-api.ts and TransactionHistory.tsx replacing offset state with page-based navigation and proper "Showing X-Y of Z" display. The conversations list endpoint was changed from returning an unpaginated array to a paginated response using .findAndCount() with skip/take. Each backend preserves its existing naming convention (snake_case for myfans-backend/, camelCase for backend/) to avoid breaking unrelated consumers.

Breaking Changes

  • Earnings API: GET /earnings/transactions and GET /earnings/withdrawals now accept page/limit query params instead of offset/limit, and return a paginated envelope ({ items, total, page, limit, total_pages }) instead of a plain array. Frontend updated in this PR.
  • Messages API: GET /conversations/:id/messages response key changed from messages to items, with added pagination metadata (total, page, limit, total_pages).
  • Conversations API: GET /conversations now returns a paginated envelope instead of a plain array.

Closes: #217

Copy link
Contributor

@aji70 aji70 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have some errors and the cli is failing please check and resolve

# Conflicts:
#	frontend/src/components/earnings/TransactionHistory.tsx
#	myfans-backend/src/posts/posts.service.ts
@aji70
Copy link
Contributor

aji70 commented Feb 25, 2026

@okekefrancis112 cli is failing

@okekefrancis112
Copy link
Contributor Author

all pass now, @aji70

@okekefrancis112
Copy link
Contributor Author

you have some errors and the cli is failing please check and resolve

what errors exactly, please can you point me to them. you can message me on whatsapp: +2349034781941

Copy link
Contributor

@aji70 aji70 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lfg

@aji70 aji70 merged commit 9b8d3c5 into MyFanss:main Feb 25, 2026
3 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.

Pagination standard (cursor vs offset)

2 participants