mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-10 04:22:09 +10:00
chore: move more admin over to arktype validators
This commit is contained in:
@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user