Open
Conversation
…QL schema - Add NutritionalInfo Mongoose model with MacroNutrients sub-schema (perGram/perUnit) - Add measureType field to Unit model (mass | volume) - Create NutritionalInfo GraphQL schema with CRUD resolvers and ingredient-owner auth - Add nutritionalInfosByIngredientIds batch query resolver - Register NutritionalInfo queries/mutations in schema index - Add USDA_API_KEY and EMAIL_FROM to constants and environment types
- Add explicit auth check in assertIngredientOwnerOrAdmin before ownership comparison - Add not-found checks in updateById/removeById to return clear NOT_FOUND errors instead of misleading NOT_AUTHORIZED when document is absent - Protect nutritionalInfoByIngredient query with auth guard (was unauthenticated) - Remove redundant removeFields:[] option from NutritionalInfoCreateTC
- Create api/src/schema/Usda.ts with usdaSearch and usdaFoodItem queries - Proxy calls to USDA FDC API server-side to keep API key out of client bundle - Map USDA nutrient IDs (energy=1008, protein=1003, carbs=1005, fat=1004) to typed fields - Return HTTP error details on USDA API failures - Require authentication on both queries - Register UsdaQuery in schema index
- Pass API key as X-Api-Key header instead of URL query param to prevent key exposure in logs - Add AbortController with 10s timeout to prevent indefinite hang on USDA API - Cap pageSize at 200 to prevent oversized responses - Guard usdaFoodItem against empty/missing fdcId in response body
- Create api/src/utils/nutritionalNotifications.ts that checks all recipe
ingredients for calculability after save and batches email notifications
- Group missing-data alerts by owner (ingredient owner / unit owner separately)
so each owner gets exactly one email per recipe save
- Use passport-local-mongoose username field as recipient email address
- Add post('save') hook to Recipe schema that calls sendNutritionalNotifications;
failures are caught and logged so they never fail the save response
- Replace N+1 NutritionalInfo queries with single batch $in query - Fan out User.findById + sendEmail calls concurrently with Promise.all - Clone recipe document before populate() to avoid mutating saved ObjectId refs - Remove incorrect unitOwnerId from perGram-missing case (ingredient owner's responsibility) - Add guard against dangling/unpopulated ingredient refs - Add EMAIL_FROM guard to skip notifications gracefully when not configured
…ional info - Add measureType to UNIT_FIELDS fragment (used by nutrition calc pipeline) - Add density to Ingredient inline selection in RECIPE_FIELDS_FULL - Add GET_NUTRITIONAL_INFO_BY_INGREDIENT, GET_NUTRITIONAL_INFOS_BY_INGREDIENT_IDS, and USDA_SEARCH queries - Add CREATE/UPDATE/DELETE_NUTRITIONAL_INFO mutations - Fix ApolloServerErrorCode.FORBIDDEN (not in this Apollo version) → string literal 'FORBIDDEN' - Fix args type casts in Usda resolver (args typed as unknown in graphql-compose)
- Use UNAUTHENTICATED error code (not FORBIDDEN) for unauthenticated requests - Add runtime type guard for args.query in usdaSearch resolver - Add usdaFdcId to GET_NUTRITIONAL_INFOS_BY_INGREDIENT_IDS for shape consistency
- Pure functions: quantityToFloat, calculateIngredientNutrition, sumRecipeNutrition - Supports mass/volume/countable pipelines with correct UnitConversion lookup - Add measureType: null to all Unit mocks (required now that UNIT_FIELDS includes it)
…OS on all non-calculable returns to prevent mutation, and add comprehensive unit tests
…e view - NutritionalInfoPanel, useNutritionalInfo hook, uncounted ingredient highlighting in IngredientList
…e mock, test fixes
…mock constant for ri id
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.
No description provided.