O'Reilly logo
  • Patrick S thinks this is interesting:

var routes = ('./routes');
app.get('/stories', routes.stories.findStories);
app.post('/stories', routes.stories. createStory);

This code will access index.js, which should expose the stories object (and others), which in turn is imported from the stories.js file in the routes folder:

module.exports.stories = require('./stories');
module.exports.users = require('./users);

The...

From

Cover of Pro Express.js

Note

using index.js and requiring directory to get all routes