mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-15 01:01:20 +10:00
* feat: start of library backends * feat: update backend routes and create initializer * feat: add legacy library creation * fix: resolve frontend type errors * fix: runtime errors * fix: lint
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import libraryManager from "~/server/internal/library";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
@ -13,8 +14,17 @@ export default defineEventHandler(async (h3) => {
|
||||
statusMessage: "Missing id in request params",
|
||||
});
|
||||
|
||||
const unimportedVersions =
|
||||
await libraryManager.fetchUnimportedVersions(gameId);
|
||||
const game = await prisma.game.findUnique({
|
||||
where: { id: gameId },
|
||||
select: { libraryId: true, libraryPath: 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" });
|
||||
|
||||
|
||||
@ -9,31 +9,31 @@ const ImportVersion = type({
|
||||
version: "string",
|
||||
|
||||
platform: "string",
|
||||
launch: "string?",
|
||||
launchArgs: "string?",
|
||||
setup: "string?",
|
||||
setupArgs: "string?",
|
||||
onlySetup: "boolean?",
|
||||
delta: "boolean?",
|
||||
umuId: "string?",
|
||||
launch: "string = ''",
|
||||
launchArgs: "string = ''",
|
||||
setup: "string = ''",
|
||||
setupArgs: "string = ''",
|
||||
onlySetup: "boolean = false",
|
||||
delta: "boolean = false",
|
||||
umuId: "string = ''",
|
||||
});
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["import:version:new"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const body = await readValidatedBody(h3, ImportVersion);
|
||||
const gameId = body.id;
|
||||
const versionName = body.version;
|
||||
|
||||
const platform = body.platform;
|
||||
const launch = body.launch ?? "";
|
||||
const launchArgs = body.launchArgs ?? "";
|
||||
const setup = body.setup ?? "";
|
||||
const setupArgs = body.setupArgs ?? "";
|
||||
const onlySetup = body.onlySetup ?? false;
|
||||
const delta = body.delta ?? false;
|
||||
const umuId = body.umuId ?? "";
|
||||
const {
|
||||
id,
|
||||
version,
|
||||
platform,
|
||||
launch,
|
||||
launchArgs,
|
||||
setup,
|
||||
setupArgs,
|
||||
onlySetup,
|
||||
delta,
|
||||
umuId,
|
||||
} = await readValidatedBody(h3, ImportVersion);
|
||||
|
||||
const platformParsed = parsePlatform(platform);
|
||||
if (!platformParsed)
|
||||
@ -41,7 +41,7 @@ export default defineEventHandler(async (h3) => {
|
||||
|
||||
if (delta) {
|
||||
const validOverlayVersions = await prisma.gameVersion.count({
|
||||
where: { gameId: gameId, platform: platformParsed, delta: false },
|
||||
where: { gameId: id, platform: platformParsed, delta: false },
|
||||
});
|
||||
if (validOverlayVersions == 0)
|
||||
throw createError({
|
||||
@ -66,7 +66,7 @@ export default defineEventHandler(async (h3) => {
|
||||
}
|
||||
|
||||
// startup & delta require more complex checking logic
|
||||
const taskId = await libraryManager.importVersion(gameId, versionName, {
|
||||
const taskId = await libraryManager.importVersion(id, version, {
|
||||
platform,
|
||||
onlySetup,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user