https://github.com/MoathShreim/Nodejs-rest-api-project-structure-Express/blob/master/controllers/baseController.jsIn my opinion, database functions such as findByIdAndDelete() should be inside the service layer and the controllers should call the service layer methods, but here we don't do this. So is it ok to put database functions inside a controller when it's just one line? Because if we don't do this, we can't extend the baseController and reuse code. We could extend the baseServiceProvider, but that would make the code messier?I am not sure if we should always use controllers. I think we should, but I am not sure about it, because some seems to put everything inside the controllers without using a service layer and some put everything inside the service layer without using any controller.
Submitted November 16, 2019 at 03:37AM by jesusscript
No comments:
Post a Comment