I'm new with NestJS so I'm having a hard time understanding the basics of putting together a proper application structure. I understand that everything in Nest is built on a modular system. But I do not know how to implement it correctly and maybe one of you will tell me how to do it correctly.
I am writing a Calculator application. On the client side, the user composes the "expression" string. Further, I send this expression as a request to the server, and on the server the expression must be calculated and the result returned.
@Controller('/calculator')
export class CalculatorController {
@Post()
getResult(@Body() expressionDto: ExpressionDto): CalculationResultDto {
const { expression } = expressionDto;
const result = getResult(expression); //here is the problem
return { expression, result };
}
}
The problem is that the getResult function is a bunch of big functions. All these functions are located in the utils folder. But this is the wrong approach in Nest, because all functionality should be presented in the form of modules. Can you please tell me how to make these functions correct? Where should they be stored and in what form?