Files
drop/server/api/v2/client/context.post.ts
2025-09-20 11:21:53 +10:00

23 lines
704 B
TypeScript

import { type } from "arktype";
import { readDropValidatedBody, throwingArktype } from "~~/server/arktype";
import { defineClientEventHandler } from "~~/server/internal/clients/event-handler";
import contextManager from "~~/server/internal/downloads/coordinator";
const CreateContext = type({
game: "string",
version: "string",
}).configure(throwingArktype);
export default defineClientEventHandler(async (h3) => {
const body = await readDropValidatedBody(h3, CreateContext);
const context = await contextManager.createContext(body.game, body.version);
if (!context)
throw createError({
statusCode: 400,
message: "Invalid game or version",
});
return { context };
});