Created
May 9, 2021 13:16
-
-
Save arielweinberger/f5c02406b48bb0e145e8542c7006649f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
NestInterceptor, | |
ExecutionContext, | |
Injectable, | |
CallHandler, | |
} from '@nestjs/common'; | |
import { classToPlain } from 'class-transformer'; | |
import { map } from 'rxjs/operators'; | |
@Injectable() | |
export class TransformInterceptor implements NestInterceptor { | |
intercept(context: ExecutionContext, next: CallHandler<any>) { | |
return next.handle().pipe(map(data => classToPlain(data))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
as @royeradames and @ysuzuki19 suggests, instanceToPlain is the way to take off the deprecated. See the doc:
typestack/class-transformer@v0.5.0...v0.5.1#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80R15
Assuming v0.5.1