Lack of a common project structure in the Node-world is very frustrating. Every team I've been on has done it differently, but I've combined what I learned from each project and have been able to come up with a structure I feel is pretty sound.
I structure mine like so:
By adding a "services" concept, you can put a lot of your business logic there, and leave the controllers to simply take the HTTP request (req object in Express) and orchestrate the services. This makes your business logic much easier to test and keeps your controllers thin.
I wrote about this in much more detail here - Project structure for an Express REST API when there is no "standard way" and explain not only what the structure should look like, but what types of logic go there.
Thank you! Your article is very good. That helped me a lot :)
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.