π Description
routes/anchors.ts's GET / supports ?status=, ?q=, ?sort=/?order=, and ?format=csv, but returns the entire filtered/sorted list with no pagination β unlike routes/settlements.ts, which already uses utils/pagination.ts's paginate helper. As the anchor registry grows, this list-everything behavior doesn't scale the same way settlements already handle it.
π§© Requirements and context
- Wire
utils/pagination.ts's paginate into GET /api/v1/anchors, applied after filtering and sorting, mirroring routes/settlements.ts's existing pattern.
- CSV export (
?format=csv) should continue to ignore pagination and return every matching row, exactly as settlements' CSV export already does.
- Response shape should include a
pagination object alongside anchors, matching the settlements route's { settlements, pagination } convention.
π οΈ Suggested execution
- Modify
src/routes/anchors.ts's GET / handler to call paginate on the sorted list before building the JSON response (but after the ?format=csv branch, which returns early).
- Update
src/openapi.ts's /api/v1/anchors GET parameters list to add page/pageSize.
- Add tests in
src/routes/anchors.test.ts for paginated responses and for CSV export still returning all rows.
β
Acceptance criteria
π Security notes
N/A β read-path feature bringing anchors in line with settlements' existing pagination; no new data exposure.
π Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
π Description
routes/anchors.ts'sGET /supports?status=,?q=,?sort=/?order=, and?format=csv, but returns the entire filtered/sorted list with no pagination β unlikeroutes/settlements.ts, which already usesutils/pagination.ts'spaginatehelper. As the anchor registry grows, this list-everything behavior doesn't scale the same way settlements already handle it.π§© Requirements and context
utils/pagination.ts'spaginateintoGET /api/v1/anchors, applied after filtering and sorting, mirroringroutes/settlements.ts's existing pattern.?format=csv) should continue to ignore pagination and return every matching row, exactly as settlements' CSV export already does.paginationobject alongsideanchors, matching the settlements route's{ settlements, pagination }convention.π οΈ Suggested execution
src/routes/anchors.ts'sGET /handler to callpaginateon the sorted list before building the JSON response (but after the?format=csvbranch, which returns early).src/openapi.ts's/api/v1/anchorsGETparameters list to addpage/pageSize.src/routes/anchors.test.tsfor paginated responses and for CSV export still returning all rows.β Acceptance criteria
GET /api/v1/anchors?page=2&pageSize=10returns apaginationobject and the correct slice.GET /api/v1/anchors?format=csvstill returns every matching row regardless ofpage/pageSize.anchors.test.tsfilter/sort tests continue to pass alongside the new pagination behavior.π Security notes
N/A β read-path feature bringing anchors in line with settlements' existing pagination; no new data exposure.
π Guidelines