How to use the @tsed/di.ProviderType.MIDDLEWARE 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 / test / units / socketio / class / SocketHandlersBuilder.spec.ts View on Github external
this.instance = new Test();
          this.provider = {
            store: {
              get: Sinon.stub()
            }
          };

          Store.from(Test).set("socketIO", {
            handlers: {
              use: "use"
            }
          });

          this.getStub = Sinon.stub(injector as any, "getProvider").returns({
            instance: this.instance,
            type: ProviderType.MIDDLEWARE,
            store: {
              get() {
                return MiddlewareType.ERROR;
              }
            }
          });

          this.scope = {scope: "scope"};
          this.error = new Error("test");

          this.builder = new SocketHandlersBuilder(this.provider, {} as any, injector);
          this.invokeStub = Sinon.stub(this.builder, "invoke").resolves();

          return this.builder.bindMiddleware({target: "target"}, this.scope, Promise.reject(this.error));
        })
      );
github TypedProject / ts-express-decorators / test / units / socketio / class / SocketHandlersBuilder.spec.ts View on Github external
this.instance = new Test();
          this.provider = {
            store: {
              get: Sinon.stub()
            }
          };

          Store.from(Test).set("socketIO", {
            handlers: {
              use: "use"
            }
          });

          this.getStub = Sinon.stub(injector as any, "getProvider").returns({
            instance: this.instance,
            type: ProviderType.MIDDLEWARE,
            store: {
              get() {
                return MiddlewareType.MIDDLEWARE;
              }
            }
          });

          this.scope = {scope: "scope"};

          this.builder = new SocketHandlersBuilder(this.provider, {} as any, injector);
          this.invokeStub = Sinon.stub(this.builder, "invoke").returns({result: "result"});

          return this.builder.bindMiddleware({target: "target"}, this.scope, Promise.resolve());
        })
      );
github TypedProject / ts-express-decorators / test / units / mvc / class / HandlerBuilder.spec.ts View on Github external
before(() => {
        this.handlerMetadata = {
          type: ProviderType.MIDDLEWARE,
          target: "target"
        };
        this.handlerBuilder = new HandlerBuilder(this.handlerMetadata);
        this.buildHandlerStub = Sinon.stub(this.handlerBuilder, "buildHandler");
        this.buildHandlerStub.returns("handlerMiddleware");
        this.result = this.handlerBuilder.getHandler();
      });
github TypedProject / ts-express-decorators / packages / common / src / mvc / services / MiddlewareService.ts View on Github external
constructor(private injectorService: InjectorService) {
    super(injectorService, {filter: {type: ProviderType.MIDDLEWARE}});
  }