chore: move more admin over to arktype validators

This commit is contained in:
DecDuck
2025-05-30 13:17:21 +10:00
parent 83a9b22d82
commit 85edc4cca2
16 changed files with 193 additions and 114 deletions

View File

@ -2,11 +2,12 @@ import aclManager from "~/server/internal/acls";
import prisma from "~/server/internal/db/database";
import objectHandler from "~/server/internal/objects";
import { type } from "arktype";
import { throwingArktype } from "~/server/arktype";
const DeleteGameImage = type({
gameId: "string",
imageId: "string",
});
}).configure(throwingArktype);
export default defineEventHandler<{
body: typeof DeleteGameImage.infer;
@ -14,14 +15,8 @@ export default defineEventHandler<{
const allowed = await aclManager.allowSystemACL(h3, ["game:image:delete"]);
if (!allowed) throw createError({ statusCode: 403 });
const body = DeleteGameImage(await readBody(h3));
if (body instanceof type.errors) {
console.error(h3.path, body.summary);
throw createError({
statusCode: 400,
statusMessage: body.summary,
});
}
const body = await readValidatedBody(h3, DeleteGameImage);
const gameId = body.gameId;
const imageId = body.imageId;