diff --git a/src/routes/api/recipes/items/all_brief/+server.ts b/src/routes/api/recipes/items/all_brief/+server.ts index 481d26d..295472e 100644 --- a/src/routes/api/recipes/items/all_brief/+server.ts +++ b/src/routes/api/recipes/items/all_brief/+server.ts @@ -14,6 +14,7 @@ export const GET: RequestHandler = async ({params}) => { ).lean(); // Map to brief format with English data + // Only include first image's alt and mediapath to reduce payload const found_brief = recipes.map((recipe: any) => ({ _id: recipe._id, name: recipe.translations.en.name, @@ -25,7 +26,9 @@ export const GET: RequestHandler = async ({params}) => { season: recipe.season || [], dateModified: recipe.dateModified, germanShortName: recipe.short_name, // For language switcher - images: recipe.images || [] + images: recipe.images?.[0] + ? [{ alt: recipe.images[0].alt, mediapath: recipe.images[0].mediapath }] + : [] })) as BriefRecipeType[]; return json(JSON.parse(JSON.stringify(rand_array(found_brief)))); diff --git a/src/routes/api/rezepte/items/all_brief/+server.ts b/src/routes/api/rezepte/items/all_brief/+server.ts index 594f1ca..4ff2e08 100644 --- a/src/routes/api/rezepte/items/all_brief/+server.ts +++ b/src/routes/api/rezepte/items/all_brief/+server.ts @@ -17,7 +17,15 @@ export const GET: RequestHandler = async ({params}) => { } else { // Cache miss - fetch from DB await dbConnect(); - recipes = await Recipe.find({}, 'name short_name tags category icon description season dateModified images').lean() as BriefRecipeType[]; + const dbRecipes = await Recipe.find({}, 'name short_name tags category icon description season dateModified images').lean() as BriefRecipeType[]; + + // Only include first image's alt and mediapath to reduce payload + recipes = dbRecipes.map(recipe => ({ + ...recipe, + images: recipe.images?.[0] + ? [{ alt: recipe.images[0].alt, mediapath: recipe.images[0].mediapath }] + : [] + })) as BriefRecipeType[]; // Store in cache (1 hour TTL) await cache.set(cacheKey, JSON.stringify(recipes), 3600);