feat(search): add SearXNG client with whitelist-filtered web search
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
15
src/routes/api/recipes/search/web/+server.ts
Normal file
15
src/routes/api/recipes/search/web/+server.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { RequestHandler } from './$types';
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import { getDb } from '$lib/server/db';
|
||||
import { searchWeb } from '$lib/server/search/searxng';
|
||||
|
||||
export const GET: RequestHandler = async ({ url }) => {
|
||||
const q = url.searchParams.get('q')?.trim() ?? '';
|
||||
if (!q) error(400, { message: 'Missing ?q=' });
|
||||
try {
|
||||
const hits = await searchWeb(getDb(), q);
|
||||
return json({ query: q, hits });
|
||||
} catch (e) {
|
||||
error(502, { message: `Web search unavailable: ${(e as Error).message}` });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user