mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-17 10:11:10 +10:00
feat: import of custom platforms & file extensions
This commit is contained in:
@ -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 };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user