Skip to content

Commit d586af6

Browse files
committed
fix return values of zod parsed values
1 parent d34002b commit d586af6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/routeHandlerBuilder.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ export class RouteHandlerBuilder<
119119
return async (request, context): Promise<Response> => {
120120
try {
121121
const url = new URL(request.url);
122-
const params = context?.params || {};
123-
const query = Object.fromEntries(url.searchParams.entries());
124-
const body = request.method !== 'GET' ? await request.json() : {};
122+
let params = context?.params || {};
123+
let query = Object.fromEntries(url.searchParams.entries());
124+
let body = request.method !== 'GET' ? await request.json() : {};
125125

126126
// Validate the params against the provided schema
127127
if (this.config.paramsSchema) {
@@ -131,6 +131,7 @@ export class RouteHandlerBuilder<
131131
JSON.stringify({ message: 'Invalid params', errors: paramsResult.error.issues }),
132132
);
133133
}
134+
params = paramsResult.data;
134135
}
135136

136137
// Validate the query against the provided schema
@@ -141,6 +142,7 @@ export class RouteHandlerBuilder<
141142
JSON.stringify({ message: 'Invalid query', errors: queryResult.error.issues }),
142143
);
143144
}
145+
query = queryResult.data;
144146
}
145147

146148
// Validate the body against the provided schema
@@ -151,6 +153,7 @@ export class RouteHandlerBuilder<
151153
JSON.stringify({ message: 'Invalid body', errors: bodyResult.error.issues }),
152154
);
153155
}
156+
body = bodyResult.data;
154157
}
155158

156159
// Execute middlewares and build context

0 commit comments

Comments
 (0)