Last active
September 10, 2019 16:09
-
-
Save ahmadarif/2d12018f7467da9203a70d0b2a0341c8 to your computer and use it in GitHub Desktop.
Nest - TransformInterceptor, working with Exclude decorator
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 { ExecutionContext, Injectable, NestInterceptor, CallHandler } from '@nestjs/common'; | |
import { classToPlain } from 'class-transformer'; | |
import { Observable } from 'rxjs'; | |
import { map } from 'rxjs/operators'; | |
@Injectable() | |
export class TransformInterceptor implements NestInterceptor { | |
intercept(context: ExecutionContext, next: CallHandler): Observable<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
Add this line to
main.ts