anomic30/Storz

Decoupling the controller from the data repository

Opened this issue · 2 comments

Start Date

No response

Implementation PR

No response

Reference Issues

No response

Summary

The current structure of the API routes has the controller functions and its data accesing tightly coupled together. This development design will not allow further easy integration to any other database that is not mongodb/mongoose without changing the entire API route functions. Suggestion:
[] A separate folder for all the controllers
[] A separate folder as the data repository (where different databases data query/ mutaions functions are define)

Basic Example

For example
The route that login in the user first queries the data dabase using the mongoose findOne method on the User Object... this direct calling of mongoose method within the route controllers had directly coupled the sytem to mongodb/mongoose as the defualt database. The challenge to this is that in the nearest future if other other databases are to be integrated into the system, the change will not only be done on the database connecttion config file but also across the entire routes controllers thereby making such integration a diffult one. But having a separate repository that is resposing for the direct communication of the database method before being used by the controller will enable easy inegration.

Drawbacks

This development design will not allow further easy integration to any other database that is not mongodb/mongoose without changing the

Unresolved questions

No response

Hi @Onesco, can you start working on this?

Alright... On it