mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-20 19:51:09 +10:00
feat: annotated client routes
This commit is contained in:
@ -1,15 +1,22 @@
|
||||
import { ArkErrors, type } from "arktype";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
const Query = type({
|
||||
id: "string",
|
||||
version: "string",
|
||||
});
|
||||
|
||||
/**
|
||||
* Fetch version metadata from game ID and version name
|
||||
* @request `id` and `version` query params are required.
|
||||
*/
|
||||
export default defineClientEventHandler(async (h3) => {
|
||||
const query = getQuery(h3);
|
||||
const id = query.id?.toString();
|
||||
const version = query.version?.toString();
|
||||
if (!id || !version)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Missing id or version in query",
|
||||
});
|
||||
const query = Query(getQuery(h3));
|
||||
if (query instanceof ArkErrors)
|
||||
throw createError({ statusCode: 400, statusMessage: query.summary });
|
||||
const id = query.id;
|
||||
const version = query.version;
|
||||
|
||||
const gameVersion = await prisma.gameVersion.findUnique({
|
||||
where: {
|
||||
@ -18,6 +25,9 @@ export default defineClientEventHandler(async (h3) => {
|
||||
versionName: version,
|
||||
},
|
||||
},
|
||||
omit: {
|
||||
dropletManifest: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!gameVersion)
|
||||
|
||||
Reference in New Issue
Block a user