How to use the @loopback/core.ContextTags.KEY function in @loopback/core

To help you get started, we’ve selected a few @loopback/core 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 / authentication / src / authentication.component.ts View on Github external
// Copyright IBM Corp. 2018,2019. All Rights Reserved.
// Node module: @loopback/authentication
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {bind, Component, ContextTags, ProviderMap} from '@loopback/core';
import {AuthenticationBindings} from './keys';
import {
  AuthenticateActionProvider,
  AuthenticationStrategyProvider,
  AuthMetadataProvider,
} from './providers';

@bind({tags: {[ContextTags.KEY]: AuthenticationBindings.COMPONENT}})
export class AuthenticationComponent implements Component {
  providers?: ProviderMap;

  constructor() {
    this.providers = {
      [AuthenticationBindings.AUTH_ACTION.key]: AuthenticateActionProvider,
      [AuthenticationBindings.STRATEGY.key]: AuthenticationStrategyProvider,
      [AuthenticationBindings.METADATA.key]: AuthMetadataProvider,
    };
  }
}
github strongloop / loopback-next / packages / authorization / src / authorization-component.ts View on Github external
// Copyright IBM Corp. 2018. All Rights Reserved.
// Node module: @loopback/authorization
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {
  bind,
  Component,
  ContextTags,
  createBindingFromClass,
} from '@loopback/core';
import {AuthorizationInterceptor} from './authorize-interceptor';
import {AuthorizationBindings} from './keys';

@bind({tags: {[ContextTags.KEY]: AuthorizationBindings.COMPONENT.key}})
export class AuthorizationComponent implements Component {
  bindings = [createBindingFromClass(AuthorizationInterceptor)];
}
github strongloop / loopback-next / extensions / logging / src / logging.component.ts View on Github external
*/
export type LoggingComponentConfig = {
  /**
   * A flag to enable fluent, default to `true`
   */
  enableFluent?: boolean;
  /**
   * A flag to enable Winston-based http access log, default to `true`
   */
  enableHttpAccessLog?: boolean;
};

/**
 * A component providing logging facilities
 */
@bind({tags: {[ContextTags.KEY]: LoggingBindings.COMPONENT}})
export class LoggingComponent implements Component {
  providers: ProviderMap;
  bindings: Binding[];

  constructor(
    @config()
    loggingConfig: LoggingComponentConfig | undefined,
  ) {
    loggingConfig = {
      enableFluent: true,
      enableHttpAccessLog: true,
      ...loggingConfig,
    };
    this.providers = {
      [LoggingBindings.WINSTON_LOGGER.key]: WinstonLoggerProvider,
      [LoggingBindings.WINSTON_INVOCATION_LOGGER