mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-21 12:11:09 +10:00
partial: admin import annotations
This commit is contained in:
@ -1,19 +1,28 @@
|
||||
import { ArkErrors, type } from "arktype";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import libraryManager from "~/server/internal/library";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const Query = type({
|
||||
id: "string",
|
||||
});
|
||||
|
||||
/**
|
||||
* Fetch all versions available for import for a game (`id` in query params).
|
||||
*/
|
||||
export default defineEventHandler<{ query: typeof Query.infer }>(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["import:version:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const query = await getQuery(h3);
|
||||
const gameId = query.id?.toString();
|
||||
if (!gameId)
|
||||
const query = Query(await getQuery(h3));
|
||||
if (query instanceof ArkErrors)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Missing id in request params",
|
||||
statusMessage: "Invalid query params: " + query.summary,
|
||||
});
|
||||
|
||||
const gameId = query.id;
|
||||
|
||||
const game = await prisma.game.findUnique({
|
||||
where: { id: gameId },
|
||||
select: { libraryId: true, libraryPath: true },
|
||||
|
||||
Reference in New Issue
Block a user