(
options: MiddlewareBindingOptions = {},
)
| 128 | * @param options - Options to configure the binding |
| 129 | */ |
| 130 | export 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 |
no test coverage detected