Skip to content

Add pagination (?page=/?pageSize=) to GET /api/v1/anchors in routes/anchors.tsΒ #137

Description

@Jagadeeshftw

πŸ“Œ 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

  • GET /api/v1/anchors?page=2&pageSize=10 returns a pagination object and the correct slice.
  • GET /api/v1/anchors?format=csv still returns every matching row regardless of page/pageSize.
  • Existing anchors.test.ts filter/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

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issueapiHTTP/WebSocket APIenhancementNew feature or improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions