How to use the @loopback/metadata.MetadataInspector.getClassMetadata function in @loopback/metadata

To help you get started, we’ve selected a few @loopback/metadata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strongloop / loopback-next / packages / context / src / interceptor.ts View on Github external
loadInterceptors() {
    let interceptors =
      MetadataInspector.getMethodMetadata(
        INTERCEPT_METHOD_KEY,
        this.target,
        this.methodName,
      ) ?? [];
    const targetClass =
      typeof this.target === 'function' ? this.target : this.target.constructor;
    const classInterceptors =
      MetadataInspector.getClassMetadata(INTERCEPT_CLASS_KEY, targetClass) ??
      [];
    // Inserting class level interceptors before method level ones
    interceptors = mergeInterceptors(classInterceptors, interceptors);
    const globalInterceptors = this.getGlobalInterceptorBindingKeys();
    // Inserting global interceptors
    interceptors = mergeInterceptors(globalInterceptors, interceptors);
    debug('Interceptors for %s', this.targetName, interceptors);
    return interceptors;
  }
}
github strongloop / loopback-next / packages / context / src / binding-inspector.ts View on Github external
export function getBindingMetadata(
  target: Function,
): BindingMetadata | undefined {
  return MetadataInspector.getClassMetadata(
    BINDING_METADATA_KEY,
    target,
  );
}