Files
drop/server/api/v1/admin/library/sources/index.delete.ts
DecDuck 2056871dc9 Add UI for multi-library management #59 (#63)
* feat: add ui for library source management

* fix: lint
2025-06-01 18:33:42 +10:00

26 lines
693 B
TypeScript

import { type } from "arktype";
import { throwingArktype } from "~/server/arktype";
import aclManager from "~/server/internal/acls";
import prisma from "~/server/internal/db/database";
const DeleteLibrarySource = type({
id: "string",
}).configure(throwingArktype);
export default defineEventHandler<{ body: typeof DeleteLibrarySource.infer }>(
async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"library:sources:delete",
]);
if (!allowed) throw createError({ statusCode: 403 });
const body = await readValidatedBody(h3, DeleteLibrarySource);
return await prisma.library.delete({
where: {
id: body.id,
},
});
},
);