--

My point is, we should not split logic inside a method using if/else based on the passed Boolean parameter. As a best practice we should not write business logic inside controllers. Therefore you should not handle logic in the controller. What I suggest you is take the argument in the controller and send it to the business/service layer. In that layer you can split the logic to two methods. That’s what we do in Facade pattern. No need to create two endpoints in controller.

--

--

Chamith Madusanka
Chamith Madusanka

Written by Chamith Madusanka

Full Stack Enthusiast | JavaScript | TypeScript | ReactJs | NextJs | | NodeJs | NestJs | Serverless | Find me on Linkedin https://www.linkedin.com/in/chamith24/

No responses yet