feat(delete games): update prisma & delete games

This commit is contained in:
DecDuck
2024-12-23 21:12:32 +11:00
parent fd4a7d1981
commit 089c3e03f6
8 changed files with 111 additions and 55 deletions

View File

@ -0,0 +1,23 @@
import prisma from "~/server/internal/db/database";
import libraryManager from "~/server/internal/library";
export default defineEventHandler(async (h3) => {
const user = await h3.context.session.getAdminUser(h3);
if (!user) throw createError({ statusCode: 403 });
const query = getQuery(h3);
const gameId = query.id?.toString();
if (!gameId)
throw createError({
statusCode: 400,
statusMessage: "Missing id in query",
});
await prisma.game.delete({
where: {
id: gameId,
},
});
return {};
});