forked from Shared/esg
initial commit
This commit is contained in:
21
src/common/interceptors/response-transform.interceptor.ts
Normal file
21
src/common/interceptors/response-transform.interceptor.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import {
|
||||
CallHandler,
|
||||
ExecutionContext,
|
||||
Injectable,
|
||||
NestInterceptor,
|
||||
} from '@nestjs/common';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { BaseInquiryResponseDto } from '../dto/base-inquiry-response.dto';
|
||||
|
||||
/**
|
||||
* Ensures inquiry endpoints always emit BaseInquiryResponseDto shape.
|
||||
*/
|
||||
@Injectable()
|
||||
export class ResponseTransformInterceptor implements NestInterceptor {
|
||||
intercept(_context: ExecutionContext, next: CallHandler): Observable<unknown> {
|
||||
return next.handle().pipe(
|
||||
map((data: BaseInquiryResponseDto) => data),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user