title: Can i have multiple route files in express (nodeJs)
body: <p>I am trying to put my routes into multiple files to organize based on module.
  if i only use one file like this all works fine</p>
  
  <pre><code>const apiRoutes = require('./routes/api')
  app.use('/api', apiRoutes);
  </code></pre>
  
  <p>but when i use the below code in my index.js and register 2 files </p>
  
  <pre><code>const apiRoutes = require('./routes/api')
  const apiRoutes2 = require('./routes/leads')
  app.use(express.json());
  app.use('/api', apiRoutes);
  app.use('/leads', apiRoutes2);
  </code></pre>
  
  <p>i get this error</p>
  
  <pre><code>C:\nodeRoot\node_modules\express\lib\router\index.js:458
    throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
    ^
  
  TypeError: Router.use() requires a middleware function but got a Object
  at Function.use (C:\nodeRoot\node_modules\express\lib\router\index.js:458:13)
  at Function.&lt;anonymous&gt; (C:\nodeRoot\node_modules\express\lib\application.js:220:21)
  at Array.forEach (&lt;anonymous&gt;)
  </code></pre>
  
  <p>So not sure if you can only register 1 file for routes or what else is causing this issue</p>