mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-21 04:01:10 +10:00
fix: client route type hacking
This commit is contained in:
@ -15,6 +15,7 @@ const GetChunk = type({
|
||||
* Part of v2 download API. Intended to be client-only.
|
||||
*
|
||||
* Returns raw stream of all files requested, in order.
|
||||
* @response `application/octet-stream` stream of all files concatenated
|
||||
*/
|
||||
export default defineEventHandler<{ body: typeof GetChunk.infer }>(
|
||||
async (h3) => {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { type } from "arktype";
|
||||
import { readDropValidatedBody, throwingArktype } from "~/server/arktype";
|
||||
import { throwingArktype } from "~/server/arktype";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import contextManager from "~/server/internal/downloads/coordinator";
|
||||
|
||||
@ -11,17 +11,13 @@ const CreateContext = type({
|
||||
/**
|
||||
* Part of v2 download API. Create a download context for use with `/api/v2/client/chunk`.
|
||||
*/
|
||||
export default defineClientEventHandler<{ body: typeof CreateContext.infer }>(
|
||||
async (h3) => {
|
||||
const body = await readDropValidatedBody(h3, CreateContext);
|
||||
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",
|
||||
});
|
||||
|
||||
const context = await contextManager.createContext(body.game, body.version);
|
||||
if (!context)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Invalid game or version",
|
||||
});
|
||||
|
||||
return { context };
|
||||
},
|
||||
);
|
||||
return { context };
|
||||
}, CreateContext);
|
||||
|
||||
Reference in New Issue
Block a user