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

Function asMiddleware

packages/express/src/middleware.ts:130–154  ·  view source on GitHub ↗
(
  options: MiddlewareBindingOptions = {},
)

Source from the content-addressed store, hash-verified

128 * @param options - Options to configure the binding
129 */
130export function asMiddleware(
131 options: MiddlewareBindingOptions = {},
132): BindingTemplate {
133 return function middlewareBindingTemplate(binding) {
134 binding.apply(extensionFor(options.chain ?? DEFAULT_MIDDLEWARE_CHAIN));
135
136 if (!binding.tagMap.group) {
137 binding.tag({group: options.group ?? DEFAULT_MIDDLEWARE_GROUP});
138 }
139 const groupsBefore = options.upstreamGroups;
140 if (groupsBefore != null) {
141 binding.tag({
142 upstreamGroups:
143 typeof groupsBefore === 'string' ? [groupsBefore] : groupsBefore,
144 });
145 }
146 const groupsAfter = options.downstreamGroups;
147 if (groupsAfter != null) {
148 binding.tag({
149 downstreamGroups:
150 typeof groupsAfter === 'string' ? [groupsAfter] : groupsAfter,
151 });
152 }
153 };
154}
155
156/**
157 * Bind the middleware function or provider class to the context

Calls 3

extensionForFunction · 0.90
applyMethod · 0.80
tagMethod · 0.80

Tested by

no test coverage detected