UNPKG

@opra/nestjs

Version:

Opra NestJS module

27 lines (26 loc) 1.25 kB
import { Controller } from '@nestjs/common'; import { ExternalExceptionFilter } from '@nestjs/core/exceptions/external-exception-filter.js'; import { classes, } from '@opra/common'; var WSControllerDecoratorFactory = classes.WSControllerDecoratorFactory; const { MQControllerDecoratorFactory } = classes; /* Augment ExternalExceptionFilter to prevent error logging for Opra controllers */ const oldCatchMethod = ExternalExceptionFilter.prototype.catch; ExternalExceptionFilter.prototype.catch = function (exception, host) { const opraContext = host.getArgByIndex(3); // Prevents error logging for all Opra controllers if (opraContext && opraContext.request && opraContext.response) throw exception; oldCatchMethod(exception, host); }; /* Augment MQControllerDecoratorFactory to automatically apply @Controller() decorator */ MQControllerDecoratorFactory.augment((decorator, decoratorChain) => { decoratorChain.push((_, target) => { Controller()(target); }); }); /* Augment WSControllerDecoratorFactory to automatically apply @Controller() decorator */ WSControllerDecoratorFactory.augment((decorator, decoratorChain) => { decoratorChain.push((_, target) => { Controller()(target); }); });