Skip to content

Fix/rate limit per api - #1356

Merged
greatest0fallt1me merged 5 commits into
CalloraOrg:mainfrom
Opulencechuks:fix/rate-limit-per-api
Oct 24, 2026
Merged

greatest0fallt1me merged 5 commits into
CalloraOrg:mainfrom
Opulencechuks:fix/rate-limit-per-api

Conversation

@Opulencechuks

Copy link
Copy Markdown
Contributor

Closes #1326

### Summary
Makes the Rate Limit page dynamic and per-API at `/marketplace/:apiId/rate-limits`, replacing the hardcoded fictional "GrantFox Wave Compute API" page at `/rate-limit`.

### Changes
- **Data Model**: Added optional `rateLimits` field to `APIItem` and populated mock data across sample APIs.
- **Route Predicate**: Added `isMarketplaceSubpage` in `src/routeMatchers.ts` to cleanly route subpages like `/sla` and `/rate-limits` to `App`, with unit tests in `src/routeMatchers.test.ts`.
- **Custom Router & Redirect**: Updated `src/renderRoute.tsx` to handle subpages properly, and updated `src/App.tsx` to route `/marketplace/:apiId/rate-limits` and redirect legacy `/rate-limit` requests to `/marketplace` with an explanatory toast.
- **Route Catalogue**: Removed `/rate-limit` from `src/config/routeCatalogue.ts` and `routePrefetchers` in `App.tsx` so 404 search does not recommend obsolete paths.
- **Component**: Refactored `RateLimitCard.tsx`:
  - Dynamically fetches the API entry from `fetchCatalog(signal)`.
  - Dynamically formats page title, document title, and breadcrumb path.
  - Dynamically hides empty columns (Burst limit, Concurrent connections).
  - Handles loading, empty ("This provider has not published rate limits"), not-found, and error states.
  - Added accessible table caption naming the API and locale-aware number formatting.
  - Removed all GrantFox literals.
- **Navigation**: Added a "View rate limits" link to the API Detail page sidebar.
- **Tests**: Replaced and extended `RateLimitCard.test.tsx` and created `routeMatchers.test.ts`.

### Test Output

✓ src/routeMatchers.test.ts (7 tests)
✓ src/pages/RateLimitCard.test.tsx (8 tests)
✓ RateLimitCard
✓ shows a loading state first
✓ renders three rows and a caption naming the API
✓ omits Burst and Concurrent columns when no tier has them
✓ shows the not-published state when the API has no rateLimits
✓ shows a not-found panel for an unknown id
✓ builds a breadcrumb from the API name whose hrefs all resolve to existing routes
✓ contains no GrantFox literals
✓ ROUTE_CATALOGUE
✓ has no dead /rate-limit entry

@drips-wave

drips-wave Bot commented Oct 20, 2026

Copy link
Copy Markdown

@Opulencechuks Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me
greatest0fallt1me merged commit 536c131 into CalloraOrg:main Oct 24, 2026
1 check failed
greatest0fallt1me added a commit that referenced this pull request Oct 24, 2026
)

#1356 was squashed with only part of its changes, leaving main failing
type-check: App.tsx used useToast/Navigate without importing them and
referenced APP_ROUTES.legacyRateLimit, and RateLimitCard referenced an
undefined `api`. Its test file was a broken merge of old and new tests.

- App: import Navigate and useToast, route /marketplace/:apiId/rate-limits
  to RateLimitCard and redirect legacy /rate-limit to the Marketplace with
  a one-time toast.
- RateLimitCard: resolve the API from fetchCatalog by :apiId, build the
  table/cards from api.rateLimits, hide empty optional columns, and handle
  loading, not-published, not-found and error states.
- renderRoute: use isMarketplaceSubpage so per-API subpages reach App.
- ApiDetailPage: add a "View rate limits" link next to "View SLA".
- Tests: rewrite RateLimitCard tests, point route-splitting test at the
  per-API path.

Co-authored-by: greatest0fallt1me <greatest0fallt1me@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

Drive the Rate Limit page from the selected API instead of fixed example tiers

2 participants