I have an application in NestJS, and I'm using it in a way that, when looking in the repository, I transform to the DTO and send the DTO back to the controller, but, in the tests, my function that transforms into a DTO, is not recognized by Nest, what to do?
async findById(id: number) {
try {
const findStudent = await this.studentRepository.findOneBy({ id })
if (findStudent) return findStudent.toStudent()
throw new NotFoundException('Student not found')
} catch(error) {
throw new BadRequestException(error.message)
}
}
Should I return the service domain to the controller, or the controller receives the domain and responds to the dto (toStudent)
BadRequestException: findStudent.toStudent is not a function