mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 16:22:39 +10:00
completed game importing; partial work on version importing
This commit is contained in:
36
server/api/v1/games/front.get.ts
Normal file
36
server/api/v1/games/front.get.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const userId = await h3.context.session.getUserId(h3);
|
||||
if (!userId) throw createError({ statusCode: 403 });
|
||||
|
||||
const rawGames = await prisma.game.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
mName: true,
|
||||
mShortDescription: true,
|
||||
mBannerId: true,
|
||||
mDevelopers: {
|
||||
select: {
|
||||
id: true,
|
||||
mName: true,
|
||||
},
|
||||
},
|
||||
mPublishers: {
|
||||
select: {
|
||||
id: true,
|
||||
mName: true,
|
||||
},
|
||||
},
|
||||
versions: {
|
||||
select: {
|
||||
platform: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const games = rawGames.map((e) => ({...e, platforms: e.versions.map((e) => e.platform).filter((e, _, r) => !r.includes(e))}))
|
||||
|
||||
return games;
|
||||
});
|
||||
Reference in New Issue
Block a user