feat: external catalog search endpoint for item autofill#6
Merged
Conversation
Add GET /search/?q= (auth-guarded) that queries three free catalogs concurrently and returns normalized results so the frontend can autofill an item's name, URL and picture: - Books: Open Library (keyless) - Movies & TV: TMDB (needs TMDB_API_KEY; degrades to empty if unset) - Music: iTunes Search API (keyless) internal/search holds the dto/service/api slice; the service fans the providers out with a WaitGroup over a shared http.Client with a 4s timeout, and a failing provider yields no results rather than failing the whole search. Wired in main.go and registered as an auth-guarded route. Also stop CreateItem from clobbering a client-supplied pic_url: only scrape og:image when no picture was provided. Adds TMDB_API_KEY to config. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a new auth-guarded
GET /search/?q=endpoint that powers a search-as-you-type "Item name" field on the frontend. It queries three free catalogs concurrently and returns a normalized result shape ({category, name, url, pic_url, description}):TMDB_API_KEY; degrades to empty results if unset)How
internal/searchvertical slice (dto.go/service.go/api.go), mirroring the existing domain layout and wired by hand incmd/backend/main.go.Search(q)fans the three providers out with async.WaitGroupover a sharedhttp.Client{Timeout: 4s}. A provider that errors contributes an empty slice rather than failing the whole search.registerSearchRoutes), consistent with other mutating routes.CreateItemno longer clobbers a client-suppliedpic_url: it only scrapes og:image when no picture was provided — so a search-autofilled cover survives.TMDB_API_KEYadded toconfig.go(default empty).Config / deploy
TMDB_API_KEYmust be set on thebackCloud Run service (the deploy workflow sets no env vars, so service-level env/secrets persist across deploys):gcloud run services update back --update-env-vars TMDB_API_KEY=<key>. Free key from themoviedb.org → Settings → API. Open Library and iTunes need no key.Notes
frontrepo and depends on the pending React 18 upgrade there; it is not in this PR.go build/go testlocally (no Go toolchain on the dev machine) — relying on thego.ymlbuild+test CI on this PR.🤖 Generated with Claude Code