feat(api): add recipe detail, search, rating, favorite, cooked, comments endpoints
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
11
src/routes/api/recipes/search/+server.ts
Normal file
11
src/routes/api/recipes/search/+server.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { RequestHandler } from './$types';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { getDb } from '$lib/server/db';
|
||||
import { listRecentRecipes, searchLocal } from '$lib/server/recipes/search-local';
|
||||
|
||||
export const GET: RequestHandler = async ({ url }) => {
|
||||
const q = url.searchParams.get('q')?.trim() ?? '';
|
||||
const limit = Math.min(Number(url.searchParams.get('limit') ?? 30), 100);
|
||||
const hits = q.length >= 1 ? searchLocal(getDb(), q, limit) : listRecentRecipes(getDb(), limit);
|
||||
return json({ query: q, hits });
|
||||
};
|
||||
Reference in New Issue
Block a user