title: node_modules/express/lib/router/index.js:458 throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
body: <p>I am trying to create nodejs express application, I am facing weird issue while using routes
  This is how my server.js looks</p>
  
  <pre><code>const express = require('express');
  const bodyParser = require('body-parser');
  const path = require('path');
  const http = require('http');
  const api = require('./server/routes/api');
  
  const app = express();
  
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({extended:false}));
  
  app.use('/api',api);
  app.use(express.static(path.join(__dirname,'dist')));
  
  app.get('/',function(req,res){
  res.sendFile(path.join(__dirname,'dist/index.html'));
  });
  
  const port = process.env.port || 3000;
  
  app.set('port',port);
  const server = http.createServer(app);
  server.listen(port,function(){
  console.log('server running at port '+port);
  });
  </code></pre>
  
  <p>I am getting following error "node_modules/express/lib/router/index.js:458
        throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
  "</p>
  
  <p>Please let me know where I am going wrong</p>