Skip to content

Commit cd8772a

Browse files
committed
fix: add default param to requestHandler impl
I also figured out how to actually use a narrow impl type without it complaining.
1 parent 8f57485 commit cd8772a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/express-wrapper/src/request.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ export function routeHandler<R extends HttpRoute, Chain extends MiddlewareChain>
6161
}): RouteHandler<R>;
6262

6363
export function routeHandler<R extends HttpRoute>({
64-
middleware,
64+
middleware = [],
6565
handler,
66-
}: any): RouteHandler<R> {
66+
}: {
67+
middleware?: express.RequestHandler[];
68+
handler: ServiceFunction<R, any>;
69+
}): RouteHandler<R> {
6770
// This function wouldn't be needed if TS had value/object level existential quantification, but since it doesn't we enforce the relationship
6871
// between the middleware chain and the handler's input params with this function and then assert the result.
6972
return { middleware, handler, [MiddlewareBrand]: true } as RouteHandler<R>;

0 commit comments

Comments
 (0)