Facebook Pixel

What goes in the config folder?

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.

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.

Thin. Parse the request, call a service or model, send the response. If a controller has complex logic, move that logic to a services folder. Controllers orchestrate; they do not contain business logic.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.