Skip to content

Commit 15830f0

Browse files
committed
refactor: fix type issues in definer
1 parent 733bc3b commit 15830f0

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/core/definer.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,25 @@ type RouteOptions<
4545
tags: string[],
4646
pathParams?: ZodType<PathParamsOutput, ZodTypeDef, PathParamsInput>,
4747
queryParams?: ZodType<QueryParamsOutput, ZodTypeDef, QueryParamsInput>,
48-
action: (source: ActionSource<PathParamsOutput, QueryParamsOutput, RequestBodyOutput>, request: Req) => Response | Promise<Res>,
48+
action: (
49+
source: ActionSource<PathParamsOutput, QueryParamsOutput, RequestBodyOutput>,
50+
request: Req
51+
) => Res | Promise<Res>,
4952
responses: Record<string, ResponseDefinition>,
50-
handleErrors?: (errorType: typeof customErrorTypes[number] | "UNKNOWN_ERROR", issues?: ZodIssue[]) => Res,
51-
middleware?: (hander: RouteMethodHandler<PathParamsInput, Req, Res>) =>
52-
RouteMethodHandler<PathParamsInput, Req, Res>,
53+
handleErrors?: (
54+
errorType: typeof customErrorTypes[number] | "UNKNOWN_ERROR",
55+
issues?: ZodIssue[]
56+
) => Res,
57+
middleware?: (
58+
hander: RouteMethodHandler<PathParamsInput, Req, Res>
59+
) => RouteMethodHandler<PathParamsInput, Req, Res>,
5360
} & (RouteWithBody<RequestBodyInput, RequestBodyOutput> | RouteWithoutBody);
5461

55-
function defineRoute<M extends HttpMethod, PPI, PPO, QPI, QPO, RBI, RBO, MwReq extends Request, MwRes extends Response>(input: RouteOptions<M, PPI, PPO, QPI, QPO, RBI, RBO, MwReq, MwRes>) {
62+
function defineRoute<
63+
M extends HttpMethod, PPI, PPO, QPI, QPO, RBI, RBO, MwReq extends Request, MwRes extends Response,
64+
>(input: RouteOptions<
65+
M, PPI, PPO, QPI, QPO, RBI, RBO, MwReq, MwRes
66+
>) {
5667
const handler: RouteMethodHandler<PPI, MwReq, MwRes> = async (request, context) => {
5768
try {
5869
const { searchParams } = new URL(request.url);

0 commit comments

Comments
 (0)