Where should shared helpers go in Express?
In a utils folder. Things like the database connection, logger, email sender, and other helpers used by multiple modules live in utils.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Express Server Folder Structure Best Practices
Separate folders for config, middlewares, models, routes, controllers, and utils. Keep app.js and server.js separate. One file per concern. This is the cleanest layout for a growing Express backend.
So you can import the Express app in tests without listening on a port, and so you can swap the server startup (HTTP, HTTPS, cluster) without touching the app. app.js creates the app; server.js starts it.
Env var loading with dotenv, exported as a typed config object. By convention, all env access goes through this file so other files do not read process.env directly. This keeps config centralized.
Still have questions?
Browse all our FAQs or reach out to our support team
