How to use the @nestjs/core/helpers/execution-context-host.ExecutionContextHost function in @nestjs/core

To help you get started, weโ€™ve selected a few @nestjs/core 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 nestjs / nest / packages / microservices / context / rpc-proxy.ts View on Github external
handleError(
    exceptionsHandler: RpcExceptionsHandler,
    args: any[],
    error: T,
  ): Observable {
    const host = new ExecutionContextHost(args);
    host.setType('rpc');
    return exceptionsHandler.handle(error, host);
  }
github vendure-ecommerce / vendure / packages / core / src / api / middleware / asset-interceptor.spec.ts View on Github external
return (done: jest.DoneCallback) => {
            const toAbsoluteUrl = jest.fn().mockReturnValue('visited');
            const configService = new MockConfigService();
            configService.assetOptions.assetStorageStrategy = { toAbsoluteUrl };
            const interceptor = new AssetInterceptor(configService as any);
            const executionContext = new ExecutionContextHost([0, 0, { req: {} }]);
            const next: CallHandler = { handle: () => of(response) };

            interceptor.intercept(executionContext, next).subscribe(result => {
                assertFn(response, result, toAbsoluteUrl);
                done();
            });
        };
    }
github nestjs / nest / packages / websockets / context / ws-proxy.ts View on Github external
handleError(
    exceptionsHandler: WsExceptionsHandler,
    args: any[],
    error: T,
  ) {
    const host = new ExecutionContextHost(args);
    host.setType('ws');
    exceptionsHandler.handle(error, host);
  }
github nestjs / nest / packages / microservices / listeners-controller.ts View on Github external
defaultCallMetadata,
        );
        return proxy(...args);
      } catch (err) {
        let exceptionFilter = this.exceptionFiltersCache.get(
          instance[methodKey],
        );
        if (!exceptionFilter) {
          exceptionFilter = this.exceptionFiltersContext.create(
            instance,
            instance[methodKey],
            moduleKey,
          );
          this.exceptionFiltersCache.set(instance[methodKey], exceptionFilter);
        }
        const host = new ExecutionContextHost(args);
        host.setType('rpc');
        exceptionFilter.handle(err, host);
      }
    };
  }