Current behavior:
The GET /api/settlements endpoint returns paginated data but the envelope structure differs from other list endpoints. There is no shared PaginatedResponse<T> type.
Expected behavior:
Define a generic PaginatedResponse<T> in @bettapay/types:
interface PaginationMeta {
page: number;
limit: number;
total: number;
totalPages: number;
hasNext: boolean;
hasPrev: boolean;
}
interface PaginatedResponse<T> { data: T[]; pagination: PaginationMeta; }
Refactor the settlement listing (gateway + settlement-engine), event listing (indexer), and any other list endpoints to use this envelope. Update corresponding Zod schemas.
Files to modify:
shared/types/index.ts — add types
shared/validation/schemas.ts — update response schemas
services/api-gateway/src/index.ts, services/settlement-engine/src/index.ts, services/indexer/src/index.ts
Edge cases:
totalPages must be 0 when total is 0 (not 1).
hasNext must be false when on last page or total is 0.
- When
limit exceeds a maximum (e.g., 100), return 422.
Test requirements:
- Page 1 with 5 items, 13 total — verify
page=1, totalPages=3, hasNext=true, hasPrev=false.
- Page 3 with 5 items — verify
hasNext=false, hasPrev=true.
- Fetch with limit > 100 — verify 400.
Acceptance criteria:
- All list endpoints return the identical
PaginatedResponse envelope.
@bettapay/types exports both types.
Current behavior:
The
GET /api/settlementsendpoint returns paginated data but the envelope structure differs from other list endpoints. There is no sharedPaginatedResponse<T>type.Expected behavior:
Define a generic
PaginatedResponse<T>in@bettapay/types:Refactor the settlement listing (gateway + settlement-engine), event listing (indexer), and any other list endpoints to use this envelope. Update corresponding Zod schemas.
Files to modify:
shared/types/index.ts— add typesshared/validation/schemas.ts— update response schemasservices/api-gateway/src/index.ts,services/settlement-engine/src/index.ts,services/indexer/src/index.tsEdge cases:
totalPagesmust be 0 whentotalis 0 (not 1).hasNextmust be false when on last page or total is 0.limitexceeds a maximum (e.g., 100), return 422.Test requirements:
page=1,totalPages=3,hasNext=true,hasPrev=false.hasNext=false,hasPrev=true.Acceptance criteria:
PaginatedResponseenvelope.@bettapay/typesexports both types.