mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-20 19:51:09 +10:00
partial: add admin game annotations
This commit is contained in:
@ -1,6 +1,10 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
/**
|
||||
* Delete a game from this instance
|
||||
* @param id Game ID
|
||||
*/
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:delete"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
@ -2,6 +2,10 @@ import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import libraryManager from "~/server/internal/library";
|
||||
|
||||
/**
|
||||
* Fetch a game by ID
|
||||
* @param id Game ID
|
||||
*/
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
/**
|
||||
* Update a game's metadata
|
||||
* @request Partial of data returned by GET
|
||||
* @param id Game ID
|
||||
*/
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:update"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
@ -3,6 +3,11 @@ import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import { handleFileUpload } from "~/server/internal/utils/handlefileupload";
|
||||
|
||||
/**
|
||||
* Update icon, name, and/or description
|
||||
* @request `multipart/form-data`, any file will become the icon, and `name` and `description` will become their respective fields.
|
||||
* @param id Game ID
|
||||
*/
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:update"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
@ -7,23 +7,29 @@ const PatchTags = type({
|
||||
tags: "string[]",
|
||||
}).configure(throwingArktype);
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:update"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
/**
|
||||
* Update the tags associated with this game.
|
||||
* @param id Game ID
|
||||
*/
|
||||
export default defineEventHandler<{ body: typeof PatchTags.infer }>(
|
||||
async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:update"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const body = await readDropValidatedBody(h3, PatchTags);
|
||||
const id = getRouterParam(h3, "id")!;
|
||||
const body = await readDropValidatedBody(h3, PatchTags);
|
||||
const id = getRouterParam(h3, "id")!;
|
||||
|
||||
await prisma.game.update({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
data: {
|
||||
tags: {
|
||||
connect: body.tags.map((e) => ({ id: e })),
|
||||
await prisma.game.update({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
},
|
||||
});
|
||||
data: {
|
||||
tags: {
|
||||
connect: body.tags.map((e) => ({ id: e })),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
});
|
||||
return;
|
||||
},
|
||||
);
|
||||
|
||||
@ -9,6 +9,9 @@ const DeleteGameImage = type({
|
||||
imageId: "string",
|
||||
}).configure(throwingArktype);
|
||||
|
||||
/**
|
||||
* Delete a game's image
|
||||
*/
|
||||
export default defineEventHandler<{
|
||||
body: typeof DeleteGameImage.infer;
|
||||
}>(async (h3) => {
|
||||
|
||||
@ -2,6 +2,10 @@ import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import { handleFileUpload } from "~/server/internal/utils/handlefileupload";
|
||||
|
||||
/**
|
||||
* Upload a game to a game's image library
|
||||
* @request `multipart/form-data`. All files will be uploaded as images. Set the game ID in the `id` field.
|
||||
*/
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:image:new"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
/**
|
||||
* Fetch brief metadata on all games connected to this instance
|
||||
*/
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
@ -8,6 +8,9 @@ const DeleteVersion = type({
|
||||
versionName: "string",
|
||||
}).configure(throwingArktype);
|
||||
|
||||
/**
|
||||
* Delete a game's version
|
||||
*/
|
||||
export default defineEventHandler<{ body: typeof DeleteVersion.infer }>(
|
||||
async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, [
|
||||
|
||||
@ -8,6 +8,9 @@ const UpdateVersionOrder = type({
|
||||
versions: "string[]",
|
||||
}).configure(throwingArktype);
|
||||
|
||||
/**
|
||||
* Update the version order of a game.
|
||||
*/
|
||||
export default defineEventHandler<{ body: typeof UpdateVersionOrder.infer }>(
|
||||
async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, [
|
||||
|
||||
Reference in New Issue
Block a user