chore(chat): migrate GET /api/credits#1725
Conversation
Group 3 (Billing read) of the chat→api migration plan. Repoints
usePayment's two reads at recoup-api and deletes the now-orphan local
routes + their helpers.
- hooks/useProStatus.ts: fetches ${getClientApiBaseUrl()}/api/subscription/status
(inlines ProStatusResponse since the deleted route used to export it).
- lib/supabase/getCredits.tsx: fetches ${getClientApiBaseUrl()}/api/credits/get.
- Deleted app/api/credits/get/, app/api/subscription/status/,
lib/credits/checkAndResetCredits.ts, lib/stripe/getOrgSubscription.ts
(each only had the deleted route or that helper as a caller).
Will only merge once api PR #500 lands.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
No issues found across 6 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: This PR migrates core billing and subscription logic to an external API. Such changes involve critical business paths and require human verification of the integration.
Mirrors the api PR: drops the `accountId` query param in favor of a Privy access token, and uses the renamed paths. - useCredits: now wraps usePrivy + passes accessToken to getCredits - useProStatus: now wraps usePrivy and Bearer-authenticates against /api/subscriptions/status - getCredits: signature changes from (accountId) to (accessToken); hits /api/credits Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="hooks/useProStatus.ts">
<violation number="1" location="hooks/useProStatus.ts:13">
P1: The migrated URL appears to target the wrong endpoint (`/api/subscription` instead of `/api/subscription/status`). This can return the wrong payload or fail at runtime.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Mirrors the api refactor: there is only one subscription endpoint, so "status" was redundant. The hook now returns the full Stripe Subscription (account-level preferred over org-level) plus a `source` marker, while usePayment still derives `isSubscribed` from `data.isPro`. - hooks/useProStatus.ts → hooks/useSubscription.ts - ProStatusResponse → SubscriptionResponse (now carries `subscription: Stripe.Subscription | null` and `source: "account" | "organization" | null`) - usePayment: imports useSubscription instead Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
It's an HTTP client now (fetches /api/credits from recoup-api), not a Supabase operation. Moves to lib/credits/getCredits.ts and drops the .tsx extension since there is no JSX. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
# Conflicts: # hooks/useProStatus.ts
Repoints
useCreditsatrecoup-api(Privy bearer) and deletes chat's local/api/credits/getroute. Will only merge once api PR #500 lands.Test plan
recoup-api(network tab)