Files
drop/server/api/v2/client/context.post.ts
2025-08-10 11:36:10 +10:00

24 lines
744 B
TypeScript

import { type } from "arktype";
import { 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);
/**
* Part of v2 download API. Create a download context for use with `/api/v2/client/chunk`.
*/
export default defineClientEventHandler(async (h3, { body }) => {
const context = await contextManager.createContext(body.game, body.version);
if (!context)
throw createError({
statusCode: 400,
statusMessage: "Invalid game or version",
});
return { context };
}, CreateContext);