How to use the typedi.Container.has function in typedi

To help you get started, we’ve selected a few typedi 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 goldcaddy77 / warthog / src / schema / SchemaGenerator.ts View on Github external
import { logger, Logger } from '../core/logger';
import {
  generateEnumMapImports,
  entityToCreateInput,
  entityToCreateManyArgs,
  entityToOrderByEnum,
  entityToUpdateInput,
  entityToUpdateInputArgs,
  entityToWhereArgs,
  entityToWhereInput,
  entityToWhereUniqueInput
} from './TypeORMConverter';
import { getMetadataStorage, ModelMetadata } from '../metadata';

export class SchemaGenerator {
  static logger: Logger = Container.has('warthog.logger')
    ? Container.get('warthog.logger')
    : logger;

  static generate(
    // This will reference 'warthog in the deployed module, but we need to do a relative import in the examples library
    warthogImportPath = 'warthog'
  ): string {
    const metadata = getMetadataStorage();
    let template = `
      // This file has been auto-generated by Warthog.  Do not update directly as it
      // will be re-written.  If you need to change this file, update models or add
      // new TypeGraphQL objects
      // @ts-ignore
      import { GraphQLDateTime as DateTime } from 'graphql-iso-date';
      import { GraphQLID as ID } from 'graphql';
github mgm-interns / team-radio / server / src / config / context / Context.ts View on Github external
protected async setCurrentStation(user: User | AnonymousUser) {
    const manager = Container.has(RealTimeStationsManager) && Container.get(RealTimeStationsManager);
    if (manager) {
      this.currentStation = manager.stations.find(station => station.isExistedUser(user));
    } else {
      this.logger.error('could not locate manager');
    }
  }
}