I am using NestJs to create an API, I currently have an endpoint post that receives parameters, processes it, and responds. The problem I have is that I want to change the name of a parameter, but only at the Json level, I tried with the Expose decorator, but it changes the attribute throughout the project.
tokens.controllers.ts
@Post()
async create(@Body() createTokenDto: CreateTokenDto) {
return await this.tokensService.create(createTokenDto);
}
create-token.dto.ts
export class CreateTokenDto {
@IsString()
@IsNotEmpty()
@Length(36)
@Expose({ name: 'product_uuid' })
productUuid: string;
}
The problem with this, is that now the CreateTokenDto object has the value productUuid is always null, is there any way to change the attribute only to the json it receives?