Skip to content

Commit

Permalink
fix: support middleware provider in suppress
Browse files Browse the repository at this point in the history
  • Loading branch information
Toshimichi0915 committed Aug 10, 2023
1 parent 1684b4f commit 2f34980
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/adapters/common-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Middleware, MiddlewareChain, middleware } from "../middleware"
import { Middleware, MiddlewareChain, middleware, MiddlewareProvider } from "../middleware"
import { ServerResponse } from "http"

// the list of all HTTP methods
Expand Down Expand Up @@ -105,9 +105,10 @@ export function withMethods<
}

export function suppress<TReq, TRes, TArgs extends unknown[]>(
middleware: Middleware<TReq, TRes, TArgs, unknown[]>
provider : MiddlewareProvider<TReq, TRes, TArgs, unknown[]>
): Middleware<TReq, TRes, TArgs, []> {
return async (req, res, next, ...args) => {
const middleware = await provider
return await middleware(req, res, () => next(), ...args)
}
}

0 comments on commit 2f34980

Please sign in to comment.