4a931c7e30
CI / update (push) Successful in 1m54s
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
19 lines
669 B
TypeScript
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)));
|
|
};
|