BE33 : scope recipe discovery/filter to existing endpoints#272
Merged
TienNguyen3711 merged 2 commits intoMay 13, 2026
Merged
Conversation
recipeDiscoveryAndFilter.test.js uses jest.doMock and is incompatible with Mocha. Add .mocharc.cjs to manage ignore patterns so Mocha handles glob expansion itself, and quote the spec in package.json accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
TienNguyen3711
approved these changes
May 13, 2026
Collaborator
TienNguyen3711
left a comment
There was a problem hiding this comment.
I have checked and tested it. Approved
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.
Goal
Clarify backend responsibility for recipe discovery, filtering, and user-created recipes — and implement only the backend capabilities that are truly needed. Refine what's already there instead of multiplying APIs.
Why it matters
Recipe features were trending toward parallel discovery / filter / utility endpoints. This PR locks the scope down in code and in docs so the team doesn't keep adding routes for things the frontend can do itself.
What changed
Refined existing endpoints (no new routes)
GET /api/filter—cuisine_id,search,limit,offsetare now applied server-side via Supabase (eq,ilike,range).%and_are escaped in the search term. Dietary + allergy logic preserved. Response shape unchanged.GET /api/recipe/community— addssearch,cuisine_id,cooking_method_id,sort(latest|oldest|name),limit,offset. Pagination is enforced viarange()instead of pulling a giant slab and slicing in JS. Response gains apaginationblock; existing fields are unchanged.Tightened ownership on community share/unshare
POST /api/recipe/:id/share-communityandPOST /api/recipe/:id/unshare-communitynow deriveuserIdfromreq.user.userIdonly and ignore anyuser_idin the request body. Prevents a caller from submitting another user's recipe for community review. Returns 400 when there is no authenticated user.User recipe create / update — intentionally not duplicated
PATCH /api/recipe-library/:idremains the single update surface. No mirror endpoint added under/api/recipe/:id.model/createRecipe.jsalready pins new rows tovisibility: "user_private"andis_published: falseserver-side, so the create flow is safe as-is.Scope documented
docs/RECIPES_SCOPE.mdlists what stays backend vs. what stays frontend, the discovery endpoint contract, ownership rules, and a checklist to apply before adding any new recipe route.What was intentionally NOT added
/api/filterand/api/recipe/communityare the canonical surfaces.PATCH /api/recipe/:id— duplication of/api/recipe-library/:id.Tests
New
test/recipeDiscoveryAndFilter.test.js— 8 tests, all passing locally:/api/filter%/_cuisine_idlatestorderinguser_id, usesreq.user.userIduser_id, usesreq.user.userIdRun:
npx jest test/recipeDiscoveryAndFilter.test.jsFiles changed
controller/filterController.jscontroller/recipeController.jsdocs/RECIPES_SCOPE.mdtest/recipeDiscoveryAndFilter.test.jsTotal: 4 files, +660 / −66
Risk
Low. No breaking changes to existing response shapes. New query params are all optional; existing clients keep working unchanged. Ownership tightening on share/unshare is a security improvement — clients that were sending
user_idin the body still work, the body field is now just ignored.Definition of Done