Should controllers contain business logic?
Keep controllers thin. Put complex logic in a services folder if needed. Controllers should parse the request, call the service, and send the response.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in How to Structure a Node.js Project Folder: A Practical Layout
Separate folders for config, routes, controllers, models, middlewares, and utils. Each file has one job. This is separation of concerns and keeps the codebase maintainable.
Routes declare the endpoints and bind them to controllers. Controllers handle the request/response logic and call models. Routes are the map; controllers are the handlers.
In a utils folder. Things like the database connection, logger, email sender, and other helpers that multiple modules use live in utils.
Still have questions?
Browse all our FAQs or reach out to our support team
