mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 19:58:11 +00:00
Merge pull request #148 from Tria-plc/feat/payment-microservice
refactor: ( payment ) use rabbitmq for webhooks event
This commit is contained in:
@@ -12,6 +12,12 @@ export class HttpExceptionFilter implements ExceptionFilter {
|
||||
private readonly logger = new Logger(HttpExceptionFilter.name);
|
||||
|
||||
catch(exception: unknown, host: ArgumentsHost): void {
|
||||
// Global filter — also reached by non-HTTP (e.g. RabbitMQ) handlers. switchToHttp() would
|
||||
// yield no response object there, so re-throw and let the transport (golevelup) handle it
|
||||
// (nack/dead-letter) instead of crashing on response.status().
|
||||
if (host.getType() !== 'http') {
|
||||
throw exception;
|
||||
}
|
||||
const ctx = host.switchToHttp();
|
||||
const response = ctx.getResponse();
|
||||
const request = ctx.getRequest();
|
||||
|
||||
@@ -4,7 +4,14 @@ import { map } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class ResponseTransformInterceptor<T> implements NestInterceptor<T, any> {
|
||||
intercept(_ctx: ExecutionContext, next: CallHandler<T>): Observable<any> {
|
||||
intercept(ctx: ExecutionContext, next: CallHandler<T>): Observable<any> {
|
||||
// Only wrap HTTP responses. This interceptor is global, so it also runs for RabbitMQ
|
||||
// message handlers (golevelup uses Nest's context system) — there, wrapping the return
|
||||
// value would corrupt the handler's contract (e.g. a returned Nack would be swallowed,
|
||||
// dropping a message instead of dead-lettering it). Let non-HTTP returns pass through.
|
||||
if (ctx.getType() !== 'http') {
|
||||
return next.handle();
|
||||
}
|
||||
return next.handle().pipe(
|
||||
map((data) => ({ success: true, data, timestamp: new Date().toISOString() })),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user