Problem
GET /api/loans and GET /api/groups return all records with no pagination. When a group has hundreds of contributions or there are thousands of loans, this will cause slow responses, excessive memory usage, and poor client performance.
// loans.service.ts — no limit, no offset
return this.prisma.loan.findMany({
where: { ... },
orderBy: { requestedAt: "desc" },
});
Task
Add cursor-based or offset pagination to both endpoints:
Query Parameters
- ?page=1&limit=20 (default: page 1, limit 20, max 100)
- ?status=Pending (existing, keep)
- ?groupId=xxx (existing, keep)
- ?sortBy=amount&order=desc for loans
Response Envelope
{
"data": [...],
"meta": {
"page": 1,
"limit": 20,
"total": 143,
"totalPages": 8
}
}
Update:
- loans.service.ts — add findAll(page, limit, groupId?, status?)
- loans.controller.ts — add @apiquery decorators for all new params
- groups.service.ts — add pagination to findAll()
- groups.controller.ts — Swagger decorators
Acceptance Criteria
- Both endpoints paginated
- Response includes meta object with pagination info
- Default: page 1, limit 20
- Max limit: 100 (reject > 100 with 400)
- Swagger docs updated (@apiquery for all params)
- Unit tests for service layer with page/limit params
Problem
GET /api/loans and GET /api/groups return all records with no pagination. When a group has hundreds of contributions or there are thousands of loans, this will cause slow responses, excessive memory usage, and poor client performance.
// loans.service.ts — no limit, no offset
return this.prisma.loan.findMany({
where: { ... },
orderBy: { requestedAt: "desc" },
});
Task
Add cursor-based or offset pagination to both endpoints:
Query Parameters
Response Envelope
{
"data": [...],
"meta": {
"page": 1,
"limit": 20,
"total": 143,
"totalPages": 8
}
}
Update:
Acceptance Criteria