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

Function resolveAsGetterFromConfig

packages/context/src/inject-config.ts:171–190  ·  view source on GitHub ↗

* Resolver from `@config.getter` * @param ctx - Context object * @param injection - Injection metadata * @param session - Resolution session

(
  ctx: Context,
  injection: Injection,
  session: ResolutionSession,
)

Source from the content-addressed store, hash-verified

169 * @param session - Resolution session
170 */
171function resolveAsGetterFromConfig(
172 ctx: Context,
173 injection: Injection,
174 session: ResolutionSession,
175) {
176 assertTargetType(injection, Function, 'Getter function');
177 const bindingKey = getTargetBindingKey(injection, session);
178 const meta = injection.metadata;
179 return async function getter() {
180 // Return `undefined` if no current binding is present
181 if (!bindingKey) return undefined;
182 return ctx.getConfigAsValueOrPromise(bindingKey, meta.propertyPath, {
183 // https://github.com/loopbackio/loopback-next/issues/9041
184 // We should start with a new session for `getter` resolution to avoid
185 // possible circular dependencies
186 session: undefined,
187 optional: meta.optional,
188 });
189 };
190}
191
192/**
193 * Resolver for `@config.view`

Callers

nothing calls this directly

Calls 3

assertTargetTypeFunction · 0.90
getTargetBindingKeyFunction · 0.85

Tested by

no test coverage detected