How to use the @tsed/di.ProviderType.CONTROLLER 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 / server / utils / createInjector.ts View on Github external
export function createInjector(settings: any = {}) {
  const injector = new InjectorService();

  // Init settings
  injector.settings = createSettingsService(injector);
  injector.logger = $log;

  injector.settings.scopes = {
    ...(settings.scopes || {}),
    [ProviderType.CONTROLLER]: settings.controllerScope
  };

  // @ts-ignore
  injector.settings.set(settings);

  /* istanbul ignore next */
  if (injector.settings.env === "test") {
    injector.logger.stop();
  }

  return injector;
}
github TypedProject / ts-express-decorators / test / units / mvc / class / HandlerBuilder.spec.ts View on Github external
before(() => {
        this.handlerMetadata = {
          type: ProviderType.CONTROLLER,
          target: "target"
        };
        this.handlerBuilder = new HandlerBuilder(this.handlerMetadata);
        this.buildHandlerStub = Sinon.stub(this.handlerBuilder, "buildHandler");
        this.buildHandlerStub.returns("endpointHandler");
        this.result = this.handlerBuilder.getHandler();
      });
      it("should have called the middlewareHandler method", () => {
github TypedProject / ts-express-decorators / packages / common / src / mvc / models / ControllerProvider.ts View on Github external
constructor(provide: any) {
    super(provide);
    this.type = ProviderType.CONTROLLER;
  }
github TypedProject / ts-express-decorators / packages / common / src / mvc / services / ControllerService.ts View on Github external
constructor(
    private injectorService: InjectorService,
    @Configuration() private settings: Configuration,
    private routeService: RouteService
  ) {
    super(injectorService as any, {filter: {type: ProviderType.CONTROLLER}});
  }
github TypedProject / ts-express-decorators / packages / common / src / mvc / MvcModule.ts View on Github external
constructor(injector: InjectorService) {
    const routers = injector
      .getProviders(ProviderType.CONTROLLER)
      .map(provider => {
        if (!provider.hasParent()) {
          return new ControllerBuilder(provider as ControllerProvider).build(injector);
        }
      })
      .filter(Boolean);

    return {routers};
  }
}