Repository navigation
refactor(backend): extract ArtistSuggestionService from artists route - #1036
LucasSantana-Dev wants to merge 5 commits into
Conversation
…vice - Create ArtistSuggestionService with three-tier lookup strategy: 1. User's saved preferred artists (database) 2. User's Spotify top artists (if linked) 3. Popular artists fallback (static list) - Move 80+ popular artist names to constants/popularArtists.ts - Add Redis caching for fallback and user top artists - Reduce artists.ts route handler from 586 to 298 LOC - Update existing tests to match new behavior - All 823 backend tests passing
Move all business logic from routes/artists.ts into services/artistSuggestion.ts: - Add handler methods: handleGetSuggestions, handleSearchArtists, etc. - Validate inputs and return errors in service layer - Trim routes file from 319 to 46 LOC (meets <100 requirement) - Create unit test suite with 33 tests (89.84% coverage, exceeds 80%) - All tests passing (856 tests in backend package)
…utes Move wrapHandler and ApiError interface to src/utils/routeUtils.ts. Redefine route handlers as module-level consts; setupArtistsRoutes becomes a compact registration block (≤100 LOC spec met). Also fix Zod schema nullable fields and test cleanup: - spotifyId/imageUrl: add .nullable() to match DB columns - Remove unused `suggestions` variable in cache test - Save/restore global.fetch around mock assignment
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Your plan currently allows 1 review/hour. Refill in 59 minutes and 13 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, 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 trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 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.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Failed to generate code suggestions for PR |
|
Size Change: 0 B Total Size: 424 kB ℹ️ View Unchanged
|
|



Summary
packages/backend/src/routes/artists.ts(586 LOC) into a dedicatedArtistSuggestionServicewrapHandlerfor error handling.filter+new Set()loop with a singleSetfor O(1) dedup infetchSpotifyTopArtistswrapHandlertorouteUtilsto share across route modulesADR
docs/decisions/2026-05-23-artist-suggestion-service.md