routes/index.js
/**
 * Goes through the files in our routes directory and loads them.
 *
 * @param  directory The directory we want to recurse on.
 * @param  router    The router instance to load our routes into.
 */
Goes through the files in our routes directory and loads them.
@param  directory The directory we want to recurse on.
@param  router    The router instance to load our routes into.
Goes through the files in our routes directory and loads them . @param directory The directory we want to recurse on . @param router The router instance to load our routes into .
function requireFiles (directory, router) {
  fs.readdirSync(directory).forEach(function (fileName) {
    if(fs.lstatSync(directory + '/' + fileName).isDirectory()) {
      requireFiles(directory + '/' + fileName, router);
    } else {
      if(fileName === 'index.js' && directory === __dirname) return;
        if(validFileTypes.indexOf(fileName.split('.').pop()) === -1) return;
      console.log(directory + '/' + fileName);
      require(directory + '/' + fileName)(router);
    }
  });
}
function requireFiles ( directory , router ) { fs . readdirSync ( directory ) . forEach ( function ( fileName ) { if ( fs . lstatSync ( directory + '/' + fileName ) . isDirectory ( ) ) { requireFiles ( directory + '/' + fileName , router ) ; } else { if ( fileName === 'index.js' && directory === __dirname ) return ; if ( validFileTypes . indexOf ( fileName . split ( '.' ) . pop ( ) ) === - 1 ) return ; console . log ( directory + '/' + fileName ) ; require ( directory + '/' + fileName ) ( router ) ; } } ) ; }
Goes through the files in our routes directory and loads them.
Goes through the files in our routes directory and loads them .
// Recurse if directory // Skip this file // Skip unknown filetypes // Require the file.