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
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);
Everything is works as expected. However I came across a suggestion to have routes.js file in the root folder of the application and
Require all routes in this and then require this file in app.js
However, I am having hard time to figure out how to set it up properly. Any suggestions will be greatly appreaciated. Thanks in advance.