You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create new files where we insert business logic from routes. I mean, pull that blocks of code where it's used mongoose's models out and put it in services files. If you agree with this request, I'd appreciate you can assign me this task.
Basic Example
A common example is when a User is created, that logic which we used, encapsulates in a function from service, then call it in the routes/services. In that way, we are just concerned about calling the function and not how it works.
Decoupling services are essential for the app, in that way we can become the code more scalable and easier for testing, if the controller handled the whole application's logic and the request-handling logic, it would start to become really hard to test. Furthermore if at some point we want to migrate our database just we would have to create a new file and write the logic with the new database.
Unresolved questions
No response
The text was updated successfully, but these errors were encountered:
Start Date
No response
Implementation PR
No response
Reference Issues
No response
Summary
Create new files where we insert business logic from routes. I mean, pull that blocks of code where it's used mongoose's models out and put it in services files. If you agree with this request, I'd appreciate you can assign me this task.
Basic Example
A common example is when a User is created, that logic which we used, encapsulates in a function from service, then call it in the routes/services. In that way, we are just concerned about calling the function and not how it works.
Example:
Before
After
Drawbacks
Decoupling services are essential for the app, in that way we can become the code more scalable and easier for testing, if the controller handled the whole application's logic and the request-handling logic, it would start to become really hard to test. Furthermore if at some point we want to migrate our database just we would have to create a new file and write the logic with the new database.
Unresolved questions
No response
The text was updated successfully, but these errors were encountered: