title: How to use nested-subfloders routing in nodejs express application?
body: <p>I am working on a node project using express. I have some folders in the routes folder which include several .js files having routes. I want to keep the structure this way to keep my code neat &amp; clear. How to require the routes in app.js file neatly?</p>
  
  <ol>
  <li>Seeing this, 
  <a href="https://github.com/searsaw/express-routing-example/blob/master/app.js" rel="nofollow noreferrer">https://github.com/searsaw/express-routing-example/blob/master/app.js</a>,
  I tried simply : </li>
  </ol>
  
  <pre><code>const routes = require('./routes');
  app.use('/', routes);
  </code></pre>
  
  <p>but it doesn't work &amp; brings my routes into action.</p>
  
  <ol start="2">
  <li>Seeing this, I tried the require-dir method too, but it doesn't work as well.
  <a href="https://stackoverflow.com/questions/41908680/nodejs-express-routes-in-separete-files">Nodejs Express: Routes in separete files</a></li>
  </ol>
  
  <p>My folder structure is like :</p>
  
  <pre><code>-routes
      -admin
          -login.js
          -CRUD_event.js
          -CRUD_venue.js
       -client
           -login.js
           -CR_event.js
           -CR_venue.js
  </code></pre>
  
  <p>I don't want to mess my app.js file, 
  I know all the routes can be required separately but that would be quite of just requiring code in app.js. I want to keep the route directory structure &amp; require them in app.js in the most optimized way possible.</p>