Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/express-wrapper/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ export function routeHandler<R extends HttpRoute, Chain extends MiddlewareChain>
}): RouteHandler<R>;

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