title: How to organize routes in Nodejs Express app
body: <p>I am working on Nodejs/Express app.I used express-generator to create basic structure. For now a specify all routes in the app.js file</p>
  
  <pre><code>var indexRouter = require('./routes/index');
  var router1Router = require('./routes/router1');
  var router2Router = require('./routes/router2');
  ......
  app.use('/', indexRouter);
  app.use('/router1', router1Router);
  app.use('/router2', router2Router);
  </code></pre>
  
  <p>Everything is works as expected. However I came across a suggestion to have <strong>routes.js</strong> file in the root folder of the application and </p>
  
  <blockquote>
    <p>Require all routes in this and then require this file in app.js</p>
  </blockquote>
  
  <p>However, I am having hard time to figure out how to set it up properly.
  Any suggestions will be greatly appreaciated. Thanks in advance.</p>