//this goes inside a api folder or something var fs = require('fs') , path = require('path') , routePath = path.resolve( __dirname ) , colors = require('colors'); //this little guy will grab all the files from the /api folder //and load up the routes inside that file exports.boot = function(app) { fs.readdirSync(routePath).forEach(function(file) { //we dont need to make a route for this current file if(file !== 'index.js'){ var cleanPath = routePath + '/' + file.substr(0, file.indexOf('.')); //resolving route for cross-platform var route = path.resolve(cleanPath) console.log('--Adding routes from: '.yellow + file) //load the route require(route)(app); } }); }