import { CallHandler , ExecutionContext , Injectable , NestInterceptor } from '@nestjs/common' ; import { Observable } from 'rxjs' ; import { map } from 'rxjs/operators' ; import { classToPlain } from 'class-transformer' ; @ Injectable ( ) export class TransformInterceptor implements NestInterceptor { intercept ( context , next ) { return next . handle ( ) . pipe ( map ( ( data ) => classToPlain ( data , { excludePrefixes : [ '_id' ] } ) ) ) ; } }