feat: add artist delete endpoint (#421)#423
Conversation
* feat: add artist delete endpoint * refactor: validate artist delete access in request validator --------- Co-authored-by: Sweets Sweetman <sweetmantech@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR introduces a complete DELETE endpoint for artists at Changes
Sequence DiagramsequenceDiagram
participant Client
participant Route as API Route
participant Validate as validateDeleteArtistRequest
participant Handler as deleteArtistHandler
participant Service as deleteArtist
participant DB as Supabase
Client->>Route: DELETE /api/artists/[id]
Route->>Handler: deleteArtistHandler(request, params)
Handler->>Validate: validateDeleteArtistRequest(request, id)
Validate->>Validate: validateAccountParams(id)
alt Param Invalid
Validate-->>Handler: NextResponse (400/CORS)
else Authenticated?
Validate->>Validate: validateAuthContext(request)
alt Auth Failed
Validate-->>Handler: NextResponse (401/CORS)
else Artist Exists?
Validate->>DB: selectAccounts(artistId)
alt Not Found
Validate-->>Handler: NextResponse (404/CORS)
else Authorized?
Validate->>DB: checkAccountArtistAccess()
alt Access Denied
Validate-->>Handler: NextResponse (403/CORS)
else Valid
Validate-->>Handler: DeleteArtistRequest{artistId, requesterAccountId}
end
end
end
end
Handler->>Service: deleteArtist({artistId, requesterAccountId})
Service->>DB: deleteAccountArtistId(requesterAccountId, artistId)
Service->>DB: getAccountArtistIds({artistIds: [artistId]})
alt Remaining Associations?
Service->>Service: Skip account deletion
else No Associations
Service->>DB: deleteAccountById(artistId)
end
Service-->>Handler: artistId
Handler-->>Route: NextResponse.json({success: true, artistId}/CORS)
Route-->>Client: 200 OK
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
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 |
feat: add artist delete endpoint
refactor: validate artist delete access in request validator
Summary by cubic
Add DELETE /api/artists/{id} to let authenticated users unlink themselves from an artist and delete the artist if no owners remain. Includes validation, handler, Supabase helpers, CORS support, and tests.
New Features
account_artist_idslink, then deletes the artist if no links remain viadeleteAccountById.Refactors
Written for commit fc97310. Summary will update on new commits.
Summary by CodeRabbit