JavaScript Express Basics Parameters, Query Strings, and Modularizing Routes Modular Routes

Michael Pashkov
Michael Pashkov
22,022 Points

What for we need different routes?

What for we need different routes? apps will often have more than one routes file. Why exactly we divided routes from app.js into several files?

1 Answer

Dilip Agheda
Dilip Agheda
Full Stack JavaScript Techdegree Graduate 27,738 Points

For below reasons:

  • better modularity
  • often app.js will end up getting too large if app is big. so its good idea to seperate routes to different file. and also, if routes are too many then they get further divided into several files as well.
  • app.js will act more like a main entry point or controller which will orchastrate different aspects of the functionality.