How to use the @tsed/di.registerFactory function in @tsed/di

To help you get started, we’ve selected a few @tsed/di 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 TypedProject / ts-express-decorators / packages / common / src / config / services / ServerSettingsService.ts View on Github external
* @returns {string|number}
   */
  getHttpsPort(): {address: string; port: number} {
    return ServerSettingsService.buildAddressAndPort(this.map.get("httpsPort"));
  }

  /**
   *
   * @param settings
   */
  setHttpsPort(settings: {address: string; port: number}) {
    this.map.set("httpsPort", `${settings.address}:${settings.port}`);
  }
}

registerFactory(ServerSettingsService);
github TypedProject / ts-express-decorators / packages / common / src / server / decorators / httpServer.ts View on Github external
* }
 * ```
 *
 * > Note: TypeScript transform and store `HttpServer` as `Function` type in the metadata. So to inject a factory, you must use the `@Inject(type)` decorator.
 *
 * @param {Type} target
 * @param {string} targetKey
 * @param {TypedPropertyDescriptor | number} descriptor
 * @returns {any}
 * @decorator
 */
export function HttpServer(target: Type, targetKey: string, descriptor: TypedPropertyDescriptor | number) {
  return Inject(HttpServer)(target, targetKey, descriptor);
}

registerFactory(HttpServer);