index.js
function findRoutes (dir, fileExtensions) {
  let files = fs.readdirSync(dir)
  let resolve = f => path.join(dir, f)
  let routes = files.filter(f => fileExtensions.indexOf(path.extname(f)) !== -1).map(resolve)
  let dirs = files.filter(f => fs.statSync(path.join(dir, f)).isDirectory()).map(resolve)
  return routes.concat(...dirs.map(subdir => findRoutes(subdir, fileExtensions)))
}
function findRoutes (dir, fileExtensions) {
  let files = fs.readdirSync(dir)
  let resolve = f => path.join(dir, f)
  let routes = files.filter(f => fileExtensions.indexOf(path.extname(f)) !== -1).map(resolve)
  let dirs = files.filter(f => fs.statSync(path.join(dir, f)).isDirectory()).map(resolve)
  return routes.concat(...dirs.map(subdir => findRoutes(subdir, fileExtensions)))
}
function findRoutes ( dir , fileExtensions ) { let files = fs . readdirSync ( dir ) let resolve = f => path . join ( dir , f ) let routes = files . filter ( f => fileExtensions . indexOf ( path . extname ( f ) ) !== - 1 ) . map ( resolve ) let dirs = files . filter ( f => fs . statSync ( path . join ( dir , f ) ) . isDirectory ( ) ) . map ( resolve ) return routes . concat ( ... dirs . map ( subdir => findRoutes ( subdir , fileExtensions ) ) ) }
recursively searches for all js files inside a directory tree, and returns their full paths
recursively searches for all js files inside a directory tree and returns their full paths