import { CallHandler , ExecutionContext , Injectable , NestInterceptor } from '@nestjs/common' ; import { ResponseDto } from '../dtos/response.dto' ; import { map } from 'rxjs/operators' ; import { Observable } from 'rxjs' ; @ Injectable ( ) export class HttpResponseInterceptor < T > implements NestInterceptor < T > { param context { ExecutionContext } param next { CallHandler } returns { payload intercept ( context , next ) { const timestamp = new Date ( ) . getTime ( ) ; return next . handle ( ) . pipe ( map ( ( payload ) => { return { payload , timestamp } ; } ) ) ; } }