What goes in the routes folder vs the controllers folder?
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.
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.
In a utils folder. Things like the database connection, logger, email sender, and other helpers that multiple modules use live in utils.
Keep controllers thin. Put complex logic in a services folder if needed. Controllers should parse the request, call the service, and send the response.
Still have questions?
Browse all our FAQs or reach out to our support team
