title: Router.use() requires a middleware function but got a undefined
body: <p>I have this code in my index.js</p>
  
  <pre><code>...
  import userRoutes from './src/routes/userRoutes';
  import invoicesRoutes from './src/routes/invoicesRoutes';
  import authMiddleware from "./src/middlewares/authMiddleware";
  ...
  const app = express();
  ...
  app.use('/user', authMiddleware, userRoutes(app));
  app.use('/invoices', authMiddleware, invoicesRoutes(app));
  </code></pre>
  
  <p>my authmiddleware</p>
  
  <pre><code>const authMiddleware = (req, res, next) =&gt; {
      if (req.headers &amp;&amp; req.headers.authorization &amp;&amp; req.headers.authorization.split(' ')[0] === 'JWT') {
          console.log(req.headers.authorization.split(' ')[0]);
          next();
      } else {
          console.log('else');
          next();
      }
  };
  
  export default authMiddleware;
  </code></pre>
  
  <p>and one of my routes:</p>
  
  <pre><code>import { register, login } from '../controllers/authController';
  
  const userRoutes = (app) =&gt; {
      app.route('/user/signup')
          .post(register);
      app.route('/user/login')
          .post(login);
  };
  
  export default userRoutes;
  </code></pre>
  
  <p>I'm getting an error:</p>
  
  <blockquote>
    <p>throw new TypeError('Router.use() requires a middleware function but
    got a ' + gettype(fn))
          ^</p>
    
    <p>TypeError: Router.use() requires a middleware function but got a
    undefined</p>
  </blockquote>
  
  <p>What's wrong?</p>