feat: add server side redist patching

This commit is contained in:
DecDuck
2025-08-28 11:14:38 +10:00
parent ca7a89bbcf
commit cf3a458bdf
9 changed files with 218 additions and 71 deletions

View File

@ -0,0 +1,27 @@
import aclManager from "~/server/internal/acls";
import prisma from "~/server/internal/db/database";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, ["redist:update"]);
if (!allowed) throw createError({ statusCode: 403 });
const body = await readBody(h3);
const id = body.id;
if (!id || typeof id !== "string")
throw createError({ statusCode: 400, message: "ID required in body." });
const updateParams = body;
delete updateParams["id"];
try {
return await prisma.redist.update({
where: {
id,
},
data: updateParams,
});
} catch (e) {
throw createError({ statusCode: 400, message: (e as string)?.toString() });
}
});