feat: cut manual segment creation to dedicated POST /api/artists/{id}/segments#1679
feat: cut manual segment creation to dedicated POST /api/artists/{id}/segments#1679arpitgupta1214 wants to merge 2 commits into
Conversation
…ents
Migrate `hooks/useCreateSegments` from the local `POST /api/segments/create`
route to the dedicated `POST /api/artists/{id}/segments` endpoint with Privy
bearer auth (matches the pattern in `lib/artists/deleteArtist.ts`). The artist
target is now path-encoded and only `prompt` goes in the body.
Success is now `{ status: "success" }`-gated rather than response-level
`error` presence. Error toast surfacing is unchanged — `data.error` still
carries the handler message (including the 409 no-socials/no-fans case).
Deletes `app/api/segments/create/route.ts` since the sole caller
(`components/Segments/NoSegmentsFound.tsx` via the hook) is now cut over.
Grep confirms zero remaining references to `/api/segments/create`.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 59 minutes and 24 seconds. ⌛ 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 (3)
✨ 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 |
Following project pattern (fetchArtists, deleteArtist) — network call lives in lib/artists/*, the hook just wires Privy auth + toast feedback.
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: This is an API migration and refactor that changes the authentication method and network path for a core business feature (segment creation).
Summary
Cuts
hooks/useCreateSegmentsover to the new dedicatedPOST /api/artists/{id}/segmentsendpoint and removes the now-unused localapp/api/segments/create/route.ts.This is the chat PR in the Create capability 3-PR stack.
Changes
hooks/useCreateSegments.ts— POST to${getClientApiBaseUrl()}/api/artists/{artist_account_id}/segmentswith Privy bearer auth; body is now{ prompt }only (artist is path-encoded). Success-gate switched todata.status === "success"; error path still surfacesdata.errorvia the existingreact-toastifytoasts. Pattern mirrorslib/artists/deleteArtist.ts+hooks/useDeleteArtist.ts.app/api/segments/create/route.ts— deleted.The sole consumer (
components/Segments/NoSegmentsFound.tsx) is unchanged — it keeps itscreateSegments(refetch)call signature andloadingflag.Dependency
POST /api/artists/{id}/segmentsendpoint). Kept as draft until that merges.Left in place (intentional, out of scope)
lib/segments/createSegments.tsand downstream helpers remain — still imported bylib/tools/createSegments.ts(the AI tool wrapper). Note:lib/tools/createSegments.tsitself has no importers in chat, but removing it is a separate dead-code sweep, not this migration.Verification
npx eslint hooks/useCreateSegments.ts components/Segments/— cleangrep -rn "/api/segments/create" .— zero matchesnpx tsc --noEmit— only pre-existing unrelated errors (spotify png module, emails test)Test plan
testNoSegmentsFoundtriggers segment generation and shows the success toastfeedbackmessage viadata.errorin the error toastSummary by cubic
Moves segment creation to the dedicated
POST /api/artists/{id}/segmentsendpoint with Privy bearer auth and deletes the old local route. Extracts the network call tolib/artists/createArtistSegments.ts; UI behavior stays the same.lib/artists/createArtistSegments.tsto call${getClientApiBaseUrl()}/api/artists/{artistId}/segmentswithAuthorization: Bearer; sends{ prompt }; succeeds on{ status: "success" }, throws ondata.error.hooks/useCreateSegmentsto useusePrivy().getAccessToken()from@privy-io/react-authand delegate tocreateArtistSegments(...); success/error toasts unchanged.app/api/segments/create/route.ts;components/Segments/NoSegmentsFound.tsxunchanged.Written for commit 07ffb22. Summary will update on new commits.