So I have an express app. I use MVC model, I have Sequelize for Model layer, Handlebars for View and Express for Controller.
My app does some trivial manipulation with DB, I achieve this by extending Sequelize functions and using the Model as much as possible from inside the Controller.
However, I do have some more complex tasks which:
- work with multiple Models
- have to perform additional network data retrievals and calculations
- change many things inside DB.
Where do I put this code according to convention to maintain readability?
- I cant put it into
models/folder, it is not a SequelizeModelclass - I cant keep it inside controller code, this lowers re-usability of this code and bloats my controllers
- I cant put it into separate file inside
controllers/folder as it is not express-compatible function, therefore not a controller per-se.
I do have utils/ folder, but that seems just like a lazy choice. Ill end up with random functions I have no better place for in one place.
Where do you guys and gals put such code in your apps (code which works with Models and yet is not a part of a single one)?
EDIT
I ended up with
db/
---models/
---interactors/
------invoicing/
------user-manipulation/
...
structure