feat(acls): refactor & acl descriptions

This commit is contained in:
DecDuck
2025-02-07 17:26:23 +11:00
parent 090d2e6586
commit 0877638fc4
23 changed files with 291 additions and 253 deletions

View File

@ -1,4 +1,5 @@
import aclManager from "~/server/internal/acls";
import objectHandler from "~/server/internal/objects";
export default defineEventHandler(async (h3) => {
const id = getRouterParam(h3, "id");
@ -6,6 +7,6 @@ export default defineEventHandler(async (h3) => {
const userId = await aclManager.getUserIdACL(h3, ["object:delete"]);
const result = await h3.context.objects.deleteWithPermission(id, userId);
const result = await objectHandler.deleteWithPermission(id, userId);
return { success: result };
});

View File

@ -1,4 +1,5 @@
import aclManager from "~/server/internal/acls";
import objectHandler from "~/server/internal/objects";
export default defineEventHandler(async (h3) => {
const id = getRouterParam(h3, "id");
@ -6,7 +7,7 @@ export default defineEventHandler(async (h3) => {
const userId = await aclManager.getUserIdACL(h3, ["object:read"]);
const object = await h3.context.objects.fetchWithPermissions(id, userId);
const object = await objectHandler.fetchWithPermissions(id, userId);
if (!object)
throw createError({ statusCode: 404, statusMessage: "Object not found" });

View File

@ -1,4 +1,5 @@
import aclManager from "~/server/internal/acls";
import objectHandler from "~/server/internal/objects";
export default defineEventHandler(async (h3) => {
const id = getRouterParam(h3, "id");
@ -14,7 +15,7 @@ export default defineEventHandler(async (h3) => {
const userId = await aclManager.getUserIdACL(h3, ["object:update"]);
const buffer = Buffer.from(body);
const result = await h3.context.objects.writeWithPermissions(
const result = await objectHandler.writeWithPermissions(
id,
async () => buffer,
userId