From ac4c00a0824b3dd5efd9d459caf70c49e244c8e8 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Wed, 11 Feb 2026 09:49:44 +0100 Subject: [PATCH] refactor: merge api/recipes and api/rezepte into unified recipeLang route Consolidate duplicate recipe API routes into a single api/[recipeLang=recipeLang]/ structure. Both /api/recipes/ and /api/rezepte/ URLs continue to work via the param matcher. Shared read endpoints now serve both languages with caching for both. Also: remove dead code (5 unused components, cookie.js) and the redundant cron-execute recurring payment route. --- .../components/faith/BenedictusMedal.svelte | 83 --- .../recipes/EditableIngredients.svelte | 305 ---------- .../recipes/EditableInstructions.svelte | 275 --------- .../recipes/IngredientListList.svelte | 564 ------------------ .../recipes/RecipeLanguageSwitcher.svelte | 142 ----- src/lib/components/recipes/Search.svelte | 2 +- src/lib/server/cache.ts | 9 +- src/lib/server/recipeHelpers.ts | 57 ++ .../[recipeLang=recipeLang]/+page.server.ts | 3 +- .../[name]/+page.server.ts | 2 +- .../[recipeLang=recipeLang]/category/+page.ts | 2 +- .../category/[category]/+page.server.ts | 3 +- .../favorites/+page.server.ts | 3 +- .../icon/[icon]/+page.server.ts | 3 +- .../search/+page.server.ts | 3 +- .../season/+page.server.ts | 3 +- .../season/[month]/+page.server.ts | 3 +- .../[recipeLang=recipeLang]/tag/+page.ts | 2 +- .../tag/[tag]/+page.server.ts | 3 +- .../add/+server.ts | 0 .../base-recipes/+server.ts | 0 .../check-references/[id]/+server.ts | 0 .../delete/+server.ts | 0 .../edit/+server.ts | 0 .../favorites/+server.ts | 0 .../favorites/check/[shortName]/+server.ts | 0 .../favorites/recipes/+server.ts | 73 +++ .../img/add/+server.ts | 0 .../img/delete/+server.ts | 0 .../img/mv/+server.ts | 0 .../items/[name]/+server.ts | 160 +++++ .../items/all_brief/+server.ts | 26 + .../items/category/+server.ts | 14 + .../items/category/[category]/+server.ts | 18 + .../items/icon/+server.ts | 0 .../items/icon/[icon]/+server.ts | 18 + .../items/in_season/[month]/+server.ts | 28 + .../items/tag/+server.ts | 23 + .../items/tag/[tag]/+server.ts | 28 + .../json-ld/[name]/+server.ts | 0 .../offline-db/+server.ts | 0 .../search/+server.ts | 46 +- .../translate/+server.ts | 0 .../translate/untranslated/+server.ts | 0 .../cron-execute/+server.ts | 120 ---- .../api/recipes/favorites/recipes/+server.ts | 70 --- .../api/recipes/items/[name]/+server.ts | 149 ----- .../api/recipes/items/all_brief/+server.ts | 35 -- .../api/recipes/items/category/+server.ts | 14 - .../items/category/[category]/+server.ts | 35 -- .../api/recipes/items/icon/[icon]/+server.ts | 35 -- .../items/in_season/[month]/+server.ts | 35 -- src/routes/api/recipes/items/tag/+server.ts | 24 - .../api/recipes/items/tag/[tag]/+server.ts | 35 -- src/routes/api/recipes/search/+server.ts | 101 ---- .../api/rezepte/favorites/recipes/+server.ts | 37 -- .../api/rezepte/items/[name]/+server.ts | 70 --- .../api/rezepte/items/all_brief/+server.ts | 37 -- .../api/rezepte/items/category/+server.ts | 12 - .../items/category/[category]/+server.ts | 13 - .../api/rezepte/items/icon/[icon]/+server.ts | 13 - .../items/in_season/[month]/+server.ts | 29 - src/routes/api/rezepte/items/tag/+server.ts | 12 - .../api/rezepte/items/tag/[tag]/+server.ts | 29 - src/utils/cookie.js | 17 - 65 files changed, 479 insertions(+), 2344 deletions(-) delete mode 100644 src/lib/components/faith/BenedictusMedal.svelte delete mode 100644 src/lib/components/recipes/EditableIngredients.svelte delete mode 100644 src/lib/components/recipes/EditableInstructions.svelte delete mode 100644 src/lib/components/recipes/IngredientListList.svelte delete mode 100644 src/lib/components/recipes/RecipeLanguageSwitcher.svelte create mode 100644 src/lib/server/recipeHelpers.ts rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/add/+server.ts (100%) rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/base-recipes/+server.ts (100%) rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/check-references/[id]/+server.ts (100%) rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/delete/+server.ts (100%) rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/edit/+server.ts (100%) rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/favorites/+server.ts (100%) rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/favorites/check/[shortName]/+server.ts (100%) create mode 100644 src/routes/api/[recipeLang=recipeLang]/favorites/recipes/+server.ts rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/img/add/+server.ts (100%) rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/img/delete/+server.ts (100%) rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/img/mv/+server.ts (100%) create mode 100644 src/routes/api/[recipeLang=recipeLang]/items/[name]/+server.ts create mode 100644 src/routes/api/[recipeLang=recipeLang]/items/all_brief/+server.ts create mode 100644 src/routes/api/[recipeLang=recipeLang]/items/category/+server.ts create mode 100644 src/routes/api/[recipeLang=recipeLang]/items/category/[category]/+server.ts rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/items/icon/+server.ts (100%) create mode 100644 src/routes/api/[recipeLang=recipeLang]/items/icon/[icon]/+server.ts create mode 100644 src/routes/api/[recipeLang=recipeLang]/items/in_season/[month]/+server.ts create mode 100644 src/routes/api/[recipeLang=recipeLang]/items/tag/+server.ts create mode 100644 src/routes/api/[recipeLang=recipeLang]/items/tag/[tag]/+server.ts rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/json-ld/[name]/+server.ts (100%) rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/offline-db/+server.ts (100%) rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/search/+server.ts (70%) rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/translate/+server.ts (100%) rename src/routes/api/{rezepte => [recipeLang=recipeLang]}/translate/untranslated/+server.ts (100%) delete mode 100644 src/routes/api/cospend/recurring-payments/cron-execute/+server.ts delete mode 100644 src/routes/api/recipes/favorites/recipes/+server.ts delete mode 100644 src/routes/api/recipes/items/[name]/+server.ts delete mode 100644 src/routes/api/recipes/items/all_brief/+server.ts delete mode 100644 src/routes/api/recipes/items/category/+server.ts delete mode 100644 src/routes/api/recipes/items/category/[category]/+server.ts delete mode 100644 src/routes/api/recipes/items/icon/[icon]/+server.ts delete mode 100644 src/routes/api/recipes/items/in_season/[month]/+server.ts delete mode 100644 src/routes/api/recipes/items/tag/+server.ts delete mode 100644 src/routes/api/recipes/items/tag/[tag]/+server.ts delete mode 100644 src/routes/api/recipes/search/+server.ts delete mode 100644 src/routes/api/rezepte/favorites/recipes/+server.ts delete mode 100644 src/routes/api/rezepte/items/[name]/+server.ts delete mode 100644 src/routes/api/rezepte/items/all_brief/+server.ts delete mode 100644 src/routes/api/rezepte/items/category/+server.ts delete mode 100644 src/routes/api/rezepte/items/category/[category]/+server.ts delete mode 100644 src/routes/api/rezepte/items/icon/[icon]/+server.ts delete mode 100644 src/routes/api/rezepte/items/in_season/[month]/+server.ts delete mode 100644 src/routes/api/rezepte/items/tag/+server.ts delete mode 100644 src/routes/api/rezepte/items/tag/[tag]/+server.ts delete mode 100644 src/utils/cookie.js diff --git a/src/lib/components/faith/BenedictusMedal.svelte b/src/lib/components/faith/BenedictusMedal.svelte deleted file mode 100644 index 048dda1..0000000 --- a/src/lib/components/faith/BenedictusMedal.svelte +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/lib/components/recipes/EditableIngredients.svelte b/src/lib/components/recipes/EditableIngredients.svelte deleted file mode 100644 index 5175043..0000000 --- a/src/lib/components/recipes/EditableIngredients.svelte +++ /dev/null @@ -1,305 +0,0 @@ - - - - -
- {#each ingredients as group, groupIndex} -
- {#if group.type === 'reference'} - 🔗 Base Recipe Reference - - {#if group.labelOverride !== undefined} - updateLabelOverride(groupIndex, e)} - placeholder="Label override (optional)" - /> - {/if} - - {#if group.itemsBefore && group.itemsBefore.length > 0} -
- - {#each group.itemsBefore as item, itemIndex} -
- updateItemBefore(groupIndex, itemIndex, 'amount', e)} - placeholder="Amt" - /> - updateItemBefore(groupIndex, itemIndex, 'unit', e)} - placeholder="Unit" - /> - updateItemBefore(groupIndex, itemIndex, 'name', e)} - placeholder="Ingredient name" - /> -
- {/each} -
- {/if} - - {#if group.itemsAfter && group.itemsAfter.length > 0} -
- - {#each group.itemsAfter as item, itemIndex} -
- updateItemAfter(groupIndex, itemIndex, 'amount', e)} - placeholder="Amt" - /> - updateItemAfter(groupIndex, itemIndex, 'unit', e)} - placeholder="Unit" - /> - updateItemAfter(groupIndex, itemIndex, 'name', e)} - placeholder="Ingredient name" - /> -
- {/each} -
- {/if} - {:else} - updateIngredientGroupName(groupIndex, e)} - placeholder="Ingredient group name" - /> - {#each group.list as item, itemIndex} -
- updateIngredientItem(groupIndex, itemIndex, 'amount', e)} - placeholder="Amt" - /> - updateIngredientItem(groupIndex, itemIndex, 'unit', e)} - placeholder="Unit" - /> - updateIngredientItem(groupIndex, itemIndex, 'name', e)} - placeholder="Ingredient name" - /> -
- {/each} - {/if} -
- {/each} -
diff --git a/src/lib/components/recipes/EditableInstructions.svelte b/src/lib/components/recipes/EditableInstructions.svelte deleted file mode 100644 index d72d81e..0000000 --- a/src/lib/components/recipes/EditableInstructions.svelte +++ /dev/null @@ -1,275 +0,0 @@ - - - - -
- {#each instructions as group, groupIndex} -
- {#if group.type === 'reference'} - 🔗 Base Recipe Reference - - {#if group.labelOverride !== undefined} - updateLabelOverride(groupIndex, e)} - placeholder="Label override (optional)" - /> - {/if} - - {#if group.stepsBefore && group.stepsBefore.length > 0} -
- - {#each group.stepsBefore as step, stepIndex} -
-
{stepIndex + 1}
-