title: Fs file handler for api
body: <p>So I want to make a routes folder that has subfolders that contain routes but I don't know how to use fs with it...</p>
  <p>I only know how to get files in the routes folder and not in subfolders</p>
  <p>here is my file handler code</p>
  <pre><code>const { readdirSync } = require('fs');
  
  
  module.exports = function(app){
      readdirSync(__dirname).forEach(function(file) {
          if (file == &quot;index.js&quot;) return;
          var name = file.substr(0, file.indexOf('.'));
          const route = require('./' + name)
                  app.get(`/${route.name}`, async (req, res) =&gt; {
                  route.run(req, res)                    
                  })
      });
  }
  </code></pre>
  <p>it gets the files from the routes folder</p>
  <pre><code>-routes
    |__index.js
    |__route.js
    |__route.js
  </code></pre>
  <p>I want to make it so it gets routes from subfolders</p>
  <pre><code>-routes
    |__index.js
    |
    |__image routes
       |__route1.js
  </code></pre>
  <p>I can't find any help online...</p>