NodeJS Route Controller Service structure for ExpressJS
Model-Routes-Controllers-Services Directory Structure
For modular code structure the logic should be divided into these directories and files.
Models - The schema definition of the Model
Routes - The API routes maps to the Controllers
Controllers - The controllers handles all the logic behind validating request parameters, query, Sending Responses with correct codes.
Services - The services contains the database queries and returning objects or throwing errors
This coder will end up writing more codes. But at the end the codes will be much more maintainable and separated.