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.
This commit is contained in:
@@ -2,8 +2,7 @@ import type { PageServerLoad } from "./$types";
|
||||
import { getUserFavorites, addFavoriteStatusToRecipes } from "$lib/server/favorites";
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch, locals, params }) => {
|
||||
const isEnglish = params.recipeLang === 'recipes';
|
||||
const apiBase = isEnglish ? '/api/recipes' : '/api/rezepte';
|
||||
const apiBase = `/api/${params.recipeLang}`;
|
||||
|
||||
let current_month = new Date().getMonth() + 1
|
||||
const res_season = await fetch(`${apiBase}/items/in_season/` + current_month);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { stripHtmlTags } from '$lib/js/stripHtmlTags';
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch, params, locals }) => {
|
||||
const isEnglish = params.recipeLang === 'recipes';
|
||||
const apiBase = isEnglish ? '/api/recipes' : '/api/rezepte';
|
||||
const apiBase = `/api/${params.recipeLang}`;
|
||||
|
||||
const res = await fetch(`${apiBase}/items/${params.name}`);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { getAllCategories, isOfflineDataAvailable } from '$lib/offline/db';
|
||||
|
||||
export const load: PageLoad = async ({ fetch, params }) => {
|
||||
const isEnglish = params.recipeLang === 'recipes';
|
||||
const apiBase = isEnglish ? '/api/recipes' : '/api/rezepte';
|
||||
const apiBase = `/api/${params.recipeLang}`;
|
||||
|
||||
// Check if we should use offline data
|
||||
if (browser && isOffline() && canUseOfflineData()) {
|
||||
|
||||
@@ -2,8 +2,7 @@ import type { PageServerLoad } from "./$types";
|
||||
import { getUserFavorites, addFavoriteStatusToRecipes } from "$lib/server/favorites";
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch, locals, params }) => {
|
||||
const isEnglish = params.recipeLang === 'recipes';
|
||||
const apiBase = isEnglish ? '/api/recipes' : '/api/rezepte';
|
||||
const apiBase = `/api/${params.recipeLang}`;
|
||||
|
||||
const res = await fetch(`${apiBase}/items/category/${params.category}`);
|
||||
const items = await res.json();
|
||||
|
||||
@@ -2,8 +2,7 @@ import type { PageServerLoad } from "./$types";
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch, locals, params }) => {
|
||||
const isEnglish = params.recipeLang === 'recipes';
|
||||
const apiBase = isEnglish ? '/api/recipes' : '/api/rezepte';
|
||||
const apiBase = `/api/${params.recipeLang}`;
|
||||
const session = await locals.auth();
|
||||
|
||||
if (!session?.user?.nickname) {
|
||||
|
||||
@@ -2,8 +2,7 @@ import type { PageServerLoad } from "./$types";
|
||||
import { getUserFavorites, addFavoriteStatusToRecipes } from "$lib/server/favorites";
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch, locals, params }) => {
|
||||
const isEnglish = params.recipeLang === 'recipes';
|
||||
const apiBase = isEnglish ? '/api/recipes' : '/api/rezepte';
|
||||
const apiBase = `/api/${params.recipeLang}`;
|
||||
|
||||
const res_season = await fetch(`${apiBase}/items/icon/` + params.icon);
|
||||
const res_icons = await fetch(`/api/rezepte/items/icon`); // Icons are shared across languages
|
||||
|
||||
@@ -2,8 +2,7 @@ import type { PageServerLoad } from './$types';
|
||||
import { getUserFavorites, addFavoriteStatusToRecipes } from "$lib/server/favorites";
|
||||
|
||||
export const load: PageServerLoad = async ({ url, fetch, params, locals }) => {
|
||||
const isEnglish = params.recipeLang === 'recipes';
|
||||
const apiBase = isEnglish ? '/api/recipes' : '/api/rezepte';
|
||||
const apiBase = `/api/${params.recipeLang}`;
|
||||
|
||||
const query = url.searchParams.get('q') || '';
|
||||
const category = url.searchParams.get('category');
|
||||
|
||||
@@ -2,8 +2,7 @@ import type { PageServerLoad } from "./$types";
|
||||
import { getUserFavorites, addFavoriteStatusToRecipes } from "$lib/server/favorites";
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch, locals, params }) => {
|
||||
const isEnglish = params.recipeLang === 'recipes';
|
||||
const apiBase = isEnglish ? '/api/recipes' : '/api/rezepte';
|
||||
const apiBase = `/api/${params.recipeLang}`;
|
||||
|
||||
let current_month = new Date().getMonth() + 1
|
||||
const res_season = await fetch(`${apiBase}/items/in_season/` + current_month);
|
||||
|
||||
@@ -2,8 +2,7 @@ import type { PageServerLoad } from "./$types";
|
||||
import { getUserFavorites, addFavoriteStatusToRecipes } from "$lib/server/favorites";
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch, locals, params }) => {
|
||||
const isEnglish = params.recipeLang === 'recipes';
|
||||
const apiBase = isEnglish ? '/api/recipes' : '/api/rezepte';
|
||||
const apiBase = `/api/${params.recipeLang}`;
|
||||
|
||||
const res_season = await fetch(`${apiBase}/items/in_season/` + params.month);
|
||||
const item_season = await res_season.json();
|
||||
|
||||
@@ -5,7 +5,7 @@ import { getAllTags, isOfflineDataAvailable } from '$lib/offline/db';
|
||||
|
||||
export const load: PageLoad = async ({ fetch, params }) => {
|
||||
const isEnglish = params.recipeLang === 'recipes';
|
||||
const apiBase = isEnglish ? '/api/recipes' : '/api/rezepte';
|
||||
const apiBase = `/api/${params.recipeLang}`;
|
||||
|
||||
// Check if we should use offline data
|
||||
if (browser && isOffline() && canUseOfflineData()) {
|
||||
|
||||
@@ -2,8 +2,7 @@ import type { PageServerLoad} from "./$types";
|
||||
import { getUserFavorites, addFavoriteStatusToRecipes } from "$lib/server/favorites";
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch, locals, params }) => {
|
||||
const isEnglish = params.recipeLang === 'recipes';
|
||||
const apiBase = isEnglish ? '/api/recipes' : '/api/rezepte';
|
||||
const apiBase = `/api/${params.recipeLang}`;
|
||||
|
||||
const res_tag = await fetch(`${apiBase}/items/tag/${params.tag}`);
|
||||
const items_tag = await res_tag.json();
|
||||
|
||||
Reference in New Issue
Block a user