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