transform.interceptor.ts
source link: https://gist.github.com/arielweinberger/f5c02406b48bb0e145e8542c7006649f
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
moefar commented on Nov 15, 2021 •
Thanks, @arielweinberger
Would be great to wrap the data
parameter with parentheses in the map
method to follow the prettier.
Thanks, @arielweinberger !
classToPlain()
will be renamed to instanceToPlain()
in class-validator
.
I already checked operation of it. in your udemy cource.
import {
NestInterceptor,
ExecutionContext,
Injectable,
CallHandler,
} from '@nestjs/common';
import { instanceToPlain } 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) => instanceToPlain(data)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK