Skip to content

Commit 01c5ae5

Browse files
committed
Improve requestBody types
1 parent a79ff88 commit 01c5ae5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/helpers.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import type { HonoRequest } from "hono";
2-
import type { SafeParseReturnType, ZodType, ZodTypeDef, output } from "zod";
2+
import type z from "zod";
33

4-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
5-
export async function requestBody<T extends ZodType<any, ZodTypeDef, any>>(
4+
export async function requestBody<T extends z.ZodType = z.ZodTypeAny>(
65
req: HonoRequest,
76
schema: T,
8-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
9-
): Promise<SafeParseReturnType<any, output<T>>> {
7+
// biome-ignore lint/suspicious/noExplicitAny: Input type is `any` as it comes from the request
8+
): Promise<z.SafeParseReturnType<any, z.output<T>>> {
109
const contentType = req.header("Content-Type");
1110
if (
1211
contentType === "application/json" ||

0 commit comments

Comments
 (0)