mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-15 17:21:13 +10:00
feat: beginnings of platform & redist management
This commit is contained in:
19
server/api/v1/admin/redist/[id]/index.delete.ts
Normal file
19
server/api/v1/admin/redist/[id]/index.delete.ts
Normal file
@ -0,0 +1,19 @@
|
||||
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:delete"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const id = getRouterParam(h3, "id")!;
|
||||
|
||||
const { count } = await prisma.redist.deleteMany({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
if (count == 0) throw createError({ statusCode: 404 });
|
||||
|
||||
return;
|
||||
});
|
||||
16
server/api/v1/admin/redist/index.get.ts
Normal file
16
server/api/v1/admin/redist/index.get.ts
Normal file
@ -0,0 +1,16 @@
|
||||
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:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
return await prisma.redist.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
mName: true,
|
||||
mShortDescription: true,
|
||||
mIconObjectId: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user