Merge pull request #148 from Tria-plc/feat/payment-microservice

refactor: ( payment ) use rabbitmq for webhooks event
This commit is contained in:
Eyob T.
2026-06-14 15:24:25 +03:00
committed by GitHub
17 changed files with 396 additions and 10 deletions

View File

@@ -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();

View File

@@ -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() })),
);