user.entity.ts
@PrimaryGeneratedColumn('uuid')
id: string;
...
@Column()
@IsString()
@Exclude({ toPlainOnly: true })
password: string;
user.controller.ts
@Post()
async create(@Body() createUserDto: CreateUserDto) {
return this.usersService.create(createUserDto);
}
user.service.ts
@Injectable()
export class UsersService {
constructor(
@InjectRepository(User)
private usersRepository: Repository<User>,
) { }
async create(createUserDto: CreateUserDto) {
...
return await this.usersRepository.save(createUserDto);
}
...
}
main.ts
app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));
app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));
When I am returning post response from the service I am getting the response with password that I already excluded from entity and also globally provided with "ClassSerializerInterceptor". But in my get request of getAllUser I don't get "password" field.
I am looking for a solution that when I create a user the "password" field will not be in the response but want it internally.