In-app store, torrential backend, locales (#332)
* feat: add store nav and fixes * fix: reduce password requirement & new task error ui * fix: client webtoken fix * fix: delta versions and dockerfile * fix: use setup platforms for filter & display * fix: setup not accounted when returning valid options * feat: tighter delta version support * feat: dl/disk size * feat: offload manifest generation to torrential * fix: bump torrential * feat: remove droplet * feat: bump torrential * feat: convert locales
This commit is contained in:
@@ -1,55 +0,0 @@
|
||||
import { ArkErrors, type } from "arktype";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import type { H3Event } from "h3";
|
||||
import { castManifest } from "~/server/internal/library/manifest";
|
||||
|
||||
const AUTHORIZATION_HEADER_PREFIX = "Bearer ";
|
||||
|
||||
const Query = type({
|
||||
version: "string",
|
||||
});
|
||||
|
||||
export async function depotAuthorization(h3: H3Event) {
|
||||
const authorization = getHeader(h3, "Authorization");
|
||||
if (!authorization) throw createError({ statusCode: 403 });
|
||||
|
||||
if (!authorization.startsWith(AUTHORIZATION_HEADER_PREFIX))
|
||||
throw createError({ statusCode: 403 });
|
||||
const key = authorization.slice(AUTHORIZATION_HEADER_PREFIX.length);
|
||||
|
||||
const depot = await prisma.depot.findFirst({ where: { key } });
|
||||
if (!depot) throw createError({ statusCode: 403 });
|
||||
}
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
await depotAuthorization(h3);
|
||||
|
||||
const query = Query(getQuery(h3));
|
||||
if (query instanceof ArkErrors)
|
||||
throw createError({ statusCode: 400, message: query.summary });
|
||||
|
||||
const version = await prisma.gameVersion.findUnique({
|
||||
where: {
|
||||
versionId: query.version,
|
||||
},
|
||||
select: {
|
||||
dropletManifest: true,
|
||||
versionPath: true,
|
||||
game: {
|
||||
select: {
|
||||
library: true,
|
||||
libraryPath: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!version)
|
||||
throw createError({ statusCode: 404, message: "Game version not found" });
|
||||
|
||||
return {
|
||||
manifest: castManifest(version.dropletManifest),
|
||||
library: version.game.library,
|
||||
libraryPath: version.game.libraryPath,
|
||||
versionPath: version.versionPath,
|
||||
};
|
||||
});
|
||||
@@ -1,24 +0,0 @@
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import { depotAuthorization } from "./manifest.get";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
await depotAuthorization(h3);
|
||||
|
||||
const games = await prisma.game.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
versions: {
|
||||
select: {
|
||||
versionId: true,
|
||||
},
|
||||
where: {
|
||||
versionPath: {
|
||||
not: null
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return games;
|
||||
});
|
||||
@@ -1,17 +1,16 @@
|
||||
import type { GameVersion, Prisma } from "~/prisma/client/client";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import gameSizeManager from "~/server/internal/gamesize";
|
||||
import type { UnimportedVersionInformation } from "~/server/internal/library";
|
||||
import libraryManager from "~/server/internal/library";
|
||||
|
||||
async function getGameVersionSize<
|
||||
T extends Omit<GameVersion, "dropletManifest">,
|
||||
>(gameId: string, version: T) {
|
||||
const size = await libraryManager.getGameVersionSize(
|
||||
gameId,
|
||||
version.versionId,
|
||||
);
|
||||
return { ...version, size };
|
||||
const clientSize = await gameSizeManager.getVersionSize(version.versionId);
|
||||
const diskSize = await gameSizeManager.getVersionDiskSize(version.versionId);
|
||||
return { ...version, diskSize, clientSize };
|
||||
}
|
||||
|
||||
export type AdminFetchGameType = Prisma.GameGetPayload<{
|
||||
|
||||
@@ -10,18 +10,10 @@ export default defineEventHandler(async (h3) => {
|
||||
|
||||
const sources = await libraryManager.fetchLibraries();
|
||||
const userStats = await userStatsManager.getUserStats();
|
||||
|
||||
const biggestGamesCombined =
|
||||
await libraryManager.getBiggestGamesCombinedVersions(5);
|
||||
const biggestGamesLatest =
|
||||
await libraryManager.getBiggestGamesLatestVersions(5);
|
||||
|
||||
return {
|
||||
gameCount: await prisma.game.count(),
|
||||
version: systemConfig.getDropVersion(),
|
||||
userStats,
|
||||
sources,
|
||||
biggestGamesLatest,
|
||||
biggestGamesCombined,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -50,7 +50,12 @@ export default defineEventHandler(async (h3) => {
|
||||
where: {
|
||||
gameId: body.id,
|
||||
delta: false,
|
||||
launches: { some: { platform: platformObject.platform } },
|
||||
OR: [
|
||||
{ launches: { some: { platform: platformObject.platform } } },
|
||||
{
|
||||
setups: { some: { platform: platformObject.platform } },
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
if (validOverlayVersions == 0)
|
||||
|
||||
Reference in New Issue
Block a user