MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / toInterceptor

Function toInterceptor

packages/express/src/middleware-interceptor.ts:98–115  ·  view source on GitHub ↗
(
  firstHandler: ExpressRequestHandler,
  ...additionalHandlers: ExpressRequestHandler[]
)

Source from the content-addressed store, hash-verified

96 * @typeParam CTX - Context type
97 */
98export function toInterceptor<CTX extends Context = InvocationContext>(
99 firstHandler: ExpressRequestHandler,
100 ...additionalHandlers: ExpressRequestHandler[]
101): GenericInterceptor<CTX> {
102 if (additionalHandlers.length === 0) {
103 const handlerFn = firstHandler;
104 return toInterceptorFromExpressMiddleware<CTX>(handlerFn);
105 }
106 const handlers = [firstHandler, ...additionalHandlers];
107 const interceptorList = handlers.map(handler => toInterceptor<CTX>(handler));
108 return async (invocationCtx, next) => {
109 const middlewareChain = new GenericInterceptorChain(
110 invocationCtx,
111 interceptorList,
112 );
113 return middlewareChain.invokeInterceptors(next);
114 };
115}
116
117function toInterceptorFromExpressMiddleware<
118 CTX extends Context = InvocationContext,

Callers 8

toMiddlewareFunction · 0.90
createInterceptorFunction · 0.85
setupBindingsFunction · 0.85
valueMethod · 0.85
valueMethod · 0.85
valueMethod · 0.85
valueMethod · 0.85

Calls 2

invokeInterceptorsMethod · 0.95

Tested by

no test coverage detected