I have a class that returns the data in a specific type CreateTenantInput
export class requestDto {
@ApiProperty()
readonly name: string;
readonly tenant: string;
readonly isActive: number;
public function toInput(): CreateTenantInput {
return new CreateTenantInput(this.name, this.tenant)
}
}
to use in a function that requires this type CreateTenantInput within the controller
@Post('/create')
async createTenant(
@Body() request: requestDto)
{
//alternative solution for the Dtio
//const input:CreateTenantInput = new CreateTenantInput(request.name, request.tenant)
return await (await new CreateTenantUseCase(request.toInput(), this.tenantRepository).handler(request)).result
}