Thursday, March 24, 2022

/routes

It's expected that all routes will be implemented under the /routes directory rather than directly in app.js. Use of /routes directory also implies use of the Express Router rather than the App routing mechanism.

Express Router allows you to group routes into logical bundles and then mount them at appropriate paths using app.use() in app.js. So it's a better way to organize routes that will improve program structure and modularity.

This routing pattern - having Express Routers defined under /routes - and then mounting the routes in app.js - is what you get by default when you run Express Generator.

Post a Comment

Note: Only a member of this blog may post a comment.