Context
packages/backend/src/routes/tmdb.ts = 443 lines, 21 handlers. 13 handlers follow the exact same copy-paste pattern:
getLang(request) → TMDB service → flagNsfwFromDb → return { results, nsfwTmdbIds }
Clone handlers:
/trending (l.121)
/movies/popular (l.132)
/tv/popular (l.143)
/movies/upcoming (l.165)
/tv/trending-anime (l.154)
/tv/top_rated (l.198)
/tv/airing_today (l.209)
/tv/on_the_air (l.220)
/search (l.231)
/movie/:id/recommendations (l.288)
/tv/:id/recommendations (l.301)
/discover/mixed (l.379)
/discover/:mediaType/genre/:genreId (l.324)
Scope
Success criteria
tmdb.ts reduced to pure orchestration (< 150 lines)
- Adding a new list endpoint = 1 helper call
Parent: #145
Context
packages/backend/src/routes/tmdb.ts= 443 lines, 21 handlers. 13 handlers follow the exact same copy-paste pattern:Clone handlers:
/trending(l.121)/movies/popular(l.132)/tv/popular(l.143)/movies/upcoming(l.165)/tv/trending-anime(l.154)/tv/top_rated(l.198)/tv/airing_today(l.209)/tv/on_the_air(l.220)/search(l.231)/movie/:id/recommendations(l.288)/tv/:id/recommendations(l.301)/discover/mixed(l.379)/discover/:mediaType/genre/:genreId(l.324)Scope
buildListEndpoint(service, options?)helper to factor out the 13 handlerstmdb/list.ts,tmdb/details.ts,tmdb/discover.ts,tmdb/genres.tsSuccess criteria
tmdb.tsreduced to pure orchestration (< 150 lines)Parent: #145