Skip to content

Commit b3b1e37

Browse files
Fix issue with router() not returning matches
1 parent bc917eb commit b3b1e37

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: src/zap.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,14 @@ export function notFound() {
206206

207207
// Router ----------------------------------------------------------------------
208208

209-
export function router(...handlers: RouteHandler<HttpMethod, any, ResponseBodyType>[]) {
210-
return async function (req: ServerRequest, res: ServerResponse) {
209+
export function router(...handlers: RouteHandler<HttpMethod, any, ResponseBodyType>[]): Handler {
210+
return async function (req, res) {
211211
for (const current of handlers) {
212212
if (req.method !== current.method) continue
213213
const match = current.matchPath(req.parsedURL.pathname)
214214
if (!match) continue
215215
req.params = match.params
216-
await current(req as ServerRequest<any>, res)
216+
return await current(req as ServerRequest<any>, res)
217217
}
218218
return send(res, 404, 'Not Found')
219219
}

0 commit comments

Comments
 (0)