feat: import of custom platforms & file extensions

This commit is contained in:
DecDuck
2025-09-06 18:29:04 +10:00
parent 7266d0485b
commit fcfc30e5df
36 changed files with 13182 additions and 271 deletions

View File

@ -1,5 +1,6 @@
import aclManager from "~/server/internal/acls";
import prisma from "~/server/internal/db/database";
import { convertIDsToPlatforms } from "~/server/internal/platform/link";
export default defineEventHandler(async (h3) => {
const userId = await aclManager.getUserIdACL(h3, ["store:read"]);
@ -17,7 +18,11 @@ export default defineEventHandler(async (h3) => {
include: {
versions: {
include: {
userPlatform: true,
gameVersions: {
include: {
platform: true,
},
},
},
},
publishers: {
@ -40,8 +45,7 @@ export default defineEventHandler(async (h3) => {
},
});
if (!game)
throw createError({ statusCode: 404, message: "Game not found" });
if (!game) throw createError({ statusCode: 404, message: "Game not found" });
const rating = await prisma.gameRating.aggregate({
where: {
@ -55,5 +59,18 @@ export default defineEventHandler(async (h3) => {
},
});
return { game, rating };
const platformIDs = game.versions
.map((e) => e.gameVersions)
.flat()
.map((e) => e.platform)
.flat()
.map((e) => e.id)
.filter((e) => e !== null)
.filter((v, index, arr) => arr.findIndex((k) => k == v) == index);
const platforms = await convertIDsToPlatforms(platformIDs);
const noVersionsGame = { ...game, versions: undefined };
return { game: noVersionsGame, rating, platforms };
});