Replies: 1 comment 1 reply
-
This way you make your DTOs depend on the entity. export class UserResponseDto extends ResponseBase {
@ApiProperty({
example: '[email protected]',
description: "User's email address",
})
email: string;
.....
constructor(props: UserResponseDto) { // <- self reference
super(props);
Object.assign(this, props);
}
} And if you pass an entity to this constructor, you should whitelist properties using class-transformer, or assign them manually to avoid leaking data with |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
Is it good idea to use constructor inside response dto to create response just like new UserResponseDto(entity)?
as an addition feature we can combine this with class-transformer and Exclude/Expose decorators inside dto
Beta Was this translation helpful? Give feedback.
All reactions