mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-15 01:01:20 +10:00
26 lines
720 B
TypeScript
26 lines
720 B
TypeScript
import { type } from "arktype";
|
|
import { readDropValidatedBody, 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 readDropValidatedBody(h3, DeleteLibrarySource);
|
|
|
|
return await prisma.library.delete({
|
|
where: {
|
|
id: body.id,
|
|
},
|
|
});
|
|
},
|
|
);
|