Files
drop/server/api/v1/admin/library/sources/index.delete.ts
DecDuck e4c8d42cc8 Setup wizard & 0.3.0 release (#146)
* fix: small merge fixes

* feat: initial setup wizard

* fix: last few localization items

* fix: lint

* fix: bump version
2025-07-31 20:41:02 +10:00

30 lines
828 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";
import libraryManager from "~/server/internal/library";
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",
"setup",
]);
if (!allowed) throw createError({ statusCode: 403 });
const body = await readDropValidatedBody(h3, DeleteLibrarySource);
await prisma.library.delete({
where: {
id: body.id,
},
});
libraryManager.removeLibrary(body.id);
},
);