Files
homepage/src/routes/[recipeLang=recipeLang]/season/[month]/+page.server.ts
T
Alexander 800a544190 perf: reuse locals.session from hook instead of re-awaiting locals.auth()
hooks.server.ts already awaits auth() once and stores the result on
locals.session. In-scope loaders (recipe list + filter views, rosary,
prayers, calendar — already done — and fitness stats) were awaiting
locals.auth() a second time per request.

Switched to the existing `locals.session ?? await locals.auth()` pattern
so the hook's result is reused. Also pulls session out of Promise.all
legs since it's now synchronous when the hook ran.

Scope: loaders only — actions, /admin, /edit, /add intentionally skipped.
2026-04-23 15:06:05 +02:00

18 lines
675 B
TypeScript

import type { PageServerLoad } from "./$types";
import { getUserFavorites, addFavoriteStatusToRecipes } from "$lib/server/favorites";
export const load: PageServerLoad = async ({ fetch, locals, params }) => {
const apiBase = `/api/${params.recipeLang}`;
const res_season = await fetch(`${apiBase}/items/in_season/` + params.month);
const item_season = await res_season.json();
const session = locals.session ?? await locals.auth();
const userFavorites = await getUserFavorites(fetch, locals, params.recipeLang);
return {
month: params.month,
season: addFavoriteStatusToRecipes(item_season, userFavorites),
session
};
};