mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-10 04:22:09 +10:00
25 lines
703 B
TypeScript
25 lines
703 B
TypeScript
import aclManager from "~/server/internal/acls";
|
|
import libraryManager from "~/server/internal/library";
|
|
|
|
export default defineEventHandler(async (h3) => {
|
|
const allowed = await aclManager.allowSystemACL(h3, [
|
|
"import:game:read",
|
|
]);
|
|
if (!allowed) throw createError({ statusCode: 403 });
|
|
|
|
const query = getQuery(h3);
|
|
const search = query.q?.toString();
|
|
if (!search)
|
|
throw createError({ statusCode: 400, statusMessage: "Invalid search" });
|
|
|
|
const results = await h3.context.metadataHandler.search(search);
|
|
|
|
if (results.length == 0)
|
|
throw createError({
|
|
statusCode: 500,
|
|
statusMessage: "No metadata provider returned search results.",
|
|
});
|
|
|
|
return results;
|
|
});
|