How to use the typedi.Container.get 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 rockstat / front / src / StaticData.ts View on Github external
constructor() {
    this.log = Container.get(Logger).for(this);
    const appConfig = Container.get>(AppConfig);
    this.dev = appConfig.env === ENV_DEV;
    this.options = appConfig.static;
    // warmup lib
    for (const [key, fn] of Object.entries(this.options)) {
      this._paths.push(key);
      const raw = this.content[key] = readSync(fn);
      const size = Math.round(raw.length / 1024)
      this.log.info(`Loaded static file: ${key}/${fn} ${size}kb`)
    }
  }
github rockstat / front / src / StaticData.ts View on Github external
constructor() {
    this.log = Container.get(Logger).for(this);
    const appConfig = Container.get>(AppConfig);
    this.dev = appConfig.env === ENV_DEV;
    this.options = appConfig.static;
    // warmup lib
    for (const [key, fn] of Object.entries(this.options)) {
      this._paths.push(key);
      const raw = this.content[key] = readSync(fn);
      const size = Math.round(raw.length / 1024)
      this.log.info(`Loaded static file: ${key}/${fn} ${size}kb`)
    }
  }
github rotemgrim / rooster-x / src / main / listeners / AppListener.ts View on Github external
            promiseIpc.on("get-series", () => Container.get(MediaRepository).getSeries());
            promiseIpc.on("get-episodes", (payload) => Container.get(MediaRepository).getEpisodes(payload));
github webclipper / web-clipper / src / common / server.ts View on Github external
(url, options) => {
    const powerpackService = Container.get(IPowerpackService);
    return {
      url,
      options: {
        ...options,
        headers: {
          ...options.headers,
          token: powerpackService.accessToken || '',
          locale: localStorageService.get(LOCAL_USER_PREFERENCE_LOCALE_KEY, getLanguage()),
        },
      },
    };
  },
  { global: false }
github typeorm / typeorm-typedi-extensions / src / decorators / InjectManager.ts View on Github external
Container.registerHandler({ object, index, propertyName, value: () => {
            const connectionManager = Container.get(ConnectionManager);
            if (!connectionManager.has(connectionName))
                throw new Error(`Cannot get connection "${connectionName}" from the connection manager. ` +
                  `Make sure you have created such connection. Also make sure you have called useContainer(Container) ` +
                  `in your application before you established a connection and importing any entity.`);

            const connection = connectionManager.get(connectionName);
            const entityManager = connection.manager;
            if (!entityManager)
                throw new Error(`Entity manager was not found on "${connectionName}" connection. ` +
                  `Make sure you correctly setup connection and container usage.`);

            return entityManager;
        }});
    };
github rotemgrim / rooster-x / src / main / listeners / AppListener.ts View on Github external
            promiseIpc.on("get-all-users", () => Container.get(UserRepository).getAllUsers());
            promiseIpc.on("get-all-torrents", () => Container.get(TorrentsRepository).getAllTorrents());
github youzan / zan-proxy / src / core / App / proxy / index.ts View on Github external
this.server = await ProxyServer.create();
    this.ignorer = new Ignorer();
    this.server.use(this.ignorer.middleware.bind(this.ignorer));
    this.server.use(ip());
    this.server.use(user(Container.get(ProfileService)));
    this.server.use(endPoint(Container.get(HttpTrafficService)));
    this.server.use(
      rule({
        mockDataService: Container.get(MockDataService),
        profileService: Container.get(ProfileService),
        ruleService: Container.get(RuleService),
      }),
    );
    const pluginManager: PluginManager = Container.get(PluginManager);
    pluginManager.loadProxyMiddleware(this.server);
    this.server.use(host(Container.get(HostService), Container.get(ProfileService)));
    this.server.use(actualRequest(Container.get(HttpTrafficService)));
  }
}
github umijs / vscode-extension-umi-pro / src / extension.ts View on Github external
context.subscriptions.push(
    languages.registerCompletionItemProvider(
      SUPPORT_LANGUAGE,
      Container.get(LocaleKeyCompletionItemProvider),
      '=',
      ' ',
      ':'
    )
  );

  context.subscriptions.push(
    languages.registerDefinitionProvider(SUPPORT_LANGUAGE, Container.get(LocaleDefinitionProvider))
  );

  context.subscriptions.push(
    languages.registerReferenceProvider(SUPPORT_LANGUAGE, Container.get(ModelActionReference))
  );

  context.subscriptions.push(Container.get(UmircDecoration));

  context.subscriptions.push(Container.get(ModelEffectsGenerator));
}