Files
wanderer/web/src/routes/api/v1/search/[index]/+server.ts
2024-03-13 00:28:11 +01:00

14 lines
400 B
TypeScript

import { error, json, type RequestEvent } from "@sveltejs/kit";
export async function POST(event: RequestEvent) {
const data = await event.request.json()
try {
const r = await event.locals.ms.index(event.params.index as string).search(data.q, data.options);
return json(r);
} catch (e: any) {
console.log(e);
throw error(e.httpStatus, e)
}
}