agent: @U0AJM7X8FBR CLI - add the ability for users to create an account, upgra#326
agent: @U0AJM7X8FBR CLI - add the ability for users to create an account, upgra#326sweetmantech wants to merge 1 commit intotestfrom
Conversation
Replace getAuthenticatedAccountId (Bearer-only) with validateAuthContext in GET/POST/DELETE /api/keys handlers so CLI users authenticating via x-api-key header can manage their API keys. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThree API key handlers ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ❌ 1❌ Failed checks (1 warning)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
🧹 Nitpick comments (1)
lib/keys/createApiKeyHandler.ts (1)
19-23: Consider extracting the repeated auth gate into a shared utility (DRY).The same
validateAuthContext+instanceof NextResponse+{ accountId }extraction block now exists in all three key handlers; a small helper would reduce repetition and keep future auth changes centralized.As per coding guidelines:
**/*.{ts,tsx}: Extract shared logic into reusable utilities following Don't Repeat Yourself (DRY) principle.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/keys/createApiKeyHandler.ts` around lines 19 - 23, Extract the repeated auth gate into a small reusable helper (e.g., getAuthAccountId or requireAuth) that wraps validateAuthContext, checks for "instanceof NextResponse" and either returns the extracted { accountId } or the NextResponse directly; then replace the duplicate block in createApiKeyHandler (and the other two key handlers) with a call to this helper and early-return when it yields a NextResponse. Ensure the helper exposes a clear return type (union of accountId payload or NextResponse) and update callers to destructure accountId after the helper returns a success value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@lib/keys/createApiKeyHandler.ts`:
- Around line 19-23: Extract the repeated auth gate into a small reusable helper
(e.g., getAuthAccountId or requireAuth) that wraps validateAuthContext, checks
for "instanceof NextResponse" and either returns the extracted { accountId } or
the NextResponse directly; then replace the duplicate block in
createApiKeyHandler (and the other two key handlers) with a call to this helper
and early-return when it yields a NextResponse. Ensure the helper exposes a
clear return type (union of accountId payload or NextResponse) and update
callers to destructure accountId after the helper returns a success value.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1709eb74-1eaa-4b5b-a98c-38d9172aa499
📒 Files selected for processing (3)
lib/keys/createApiKeyHandler.tslib/keys/deleteApiKeyHandler.tslib/keys/getApiKeysHandler.ts
Automated PR from coding agent.
Prompt: @U0AJM7X8FBR CLI - add the ability for users to create an account, upgrade to pro, and create and delete their api keys
Summary by CodeRabbit