Files
homepage/src/routes/api/[recipeLang=recipeLang]/items/icon/[icon]/+server.ts
T
Alexander 4a931c7e30
CI / update (push) Successful in 1m54s
fix: resolve all 1008 svelte-check type errors across codebase
Add type annotations, JSDoc types, null checks, and proper generics
to eliminate all svelte-check errors. Key changes include:
- Type $state(null) variables to avoid 'never' inference
- Add JSDoc typedefs for plain <script> components
- Fix mongoose model typing with Model<any> to avoid union complexity
- Add App.Error/App.PageState interfaces in app.d.ts
- Fix tuple types to array types in types.ts
- Type catch block errors and API handler params
- Add null safety for DOM queries and optional chaining
- Add standard line-clamp property alongside -webkit- prefix
2026-03-02 08:40:18 +01:00

19 lines
669 B
TypeScript

import { json, type RequestHandler } from '@sveltejs/kit';
import { Recipe } from '$models/Recipe';
import { dbConnect } from '$utils/db';
import { rand_array } from '$lib/js/randomize';
import { briefQueryConfig, toBrief } from '$lib/server/recipeHelpers';
export const GET: RequestHandler = async ({ params }) => {
const { approvalFilter, projection } = briefQueryConfig(params.recipeLang!);
await dbConnect();
const dbRecipes = await Recipe.find(
{ icon: params.icon, ...approvalFilter },
projection
).lean();
const recipes = rand_array(dbRecipes.map(r => toBrief(r, params.recipeLang!)));
return json(JSON.parse(JSON.stringify(recipes)));
};