feat: cocktails list with load and download buttons#2
Merged
Conversation
Co-Authored-By: mpb <modulospb@protonmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
Adds the feature requested in the session: a button on the main page that downloads a list of cocktails from thecocktaildb, plus the cocktail names and ingredients rendered on the page.
Implementation:
GET /api/cocktails?letter={a-z}(src/routes/cocktails.js). Callssearch.php?f={letter}on thecocktaildb, flattens the 15strIngredient{n}/strMeasure{n}fields into a cleaningredients: [{ name, measure }]array, and returns[{ id, name, category, glass, thumbnail, ingredients }]. Results cached in-memory per letter for 10 min. Invalidletter→400; upstream non-OK →502.public/index.htmlserved at/viaexpress.static. Contains an input for the initial letter, a "Cargar cócteles" button that fetches/api/cocktails?letter=…and renders each cocktail as a card with name + ingredient list, and a "Descargar JSON" button that saves the fetched list ascocktails-{letter}.jsonvia a client-side Blob download.GET /→GET /api, so/can serve the HTML./healthis unchanged./api/cocktails(happy path with ingredient parsing, nulldrinks, default letter, invalid letter, upstream 5xx, and cache hit) withfetchstubbed viavi.stubGlobal.root.test.jsupdated to match the new routing (/apimetadata,/serves HTML). All 10 tests pass locally along withnpm run lintandnpm run format:check.Review & Testing Checklist for Human
fetch):npm install && npm run dev, openhttp://localhost:3000, try lettersa,m,z, and a letter with no results, plus the "Descargar JSON" button. Confirm names + ingredients render correctly and the downloaded file contains the same data.GET /now returns HTML (previously JSON metadata); JSON metadata moved toGET /api. If any external caller depended onGET /returning JSON, it will break.Notes
express.static(publicDir)is mounted before API routes. If a file underpublic/ever collides with an API path (e.g. a file namedapi), it would shadow the route — not a concern today, but worth keeping in mind.1is hardcoded, which is how their public docs instruct). Fine for a sandbox; add a limiter before exposing publicly.parseDrinkreadsstrIngredient1..15per thecocktaildb's current schema; extra fields added upstream in the future would be silently ignored.Link to Devin session: https://app.devin.ai/sessions/38829c1a13124d54a5fdf114ce348ba9
Requested by: @ModulosPB