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:
2026-04-17 15:23:00 +02:00
parent 7c62c977c4
commit 45275e56a9
6 changed files with 187 additions and 0 deletions

View 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 });
};