mirror of
https://github.com/BillyOutlast/drop.git
synced 2026-02-04 08:41:17 +01:00
* feat: game specialisation, auto-guess extensions * fix: enforce specialisation specific schema at API level * fix: lint * feat: partial work on depot endpoints * feat: bump torrential * feat: dummy version creation for depot uploads * fix: lint * fix: types * fix: lint * feat: depot version import * fix: lint * fix: remove any type * fix: lint * fix: push update interval * fix: cpu usage calculation * feat: delta version support * feat: style tweaks for selectlaunch.vue * fix: lint
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
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 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)
|
|
throw createError({
|
|
statusCode: 400,
|
|
statusMessage: "Missing id in request params",
|
|
});
|
|
|
|
const game = await prisma.game.findUnique({
|
|
where: { id: gameId },
|
|
select: { libraryId: true, libraryPath: true, type: true },
|
|
});
|
|
if (!game || !game.libraryId)
|
|
throw createError({ statusCode: 404, statusMessage: "Game not found" });
|
|
|
|
const unimportedVersions = await libraryManager.fetchUnimportedGameVersions(
|
|
game.libraryId,
|
|
game.libraryPath,
|
|
);
|
|
if (!unimportedVersions)
|
|
throw createError({ statusCode: 400, statusMessage: "Invalid game ID" });
|
|
|
|
return { versions: unimportedVersions, type: game.type };
|
|
});
|