title: how to perform crud using node.js express with mysql
body: <p>I want to perform a basic CRUD with <code>mysql</code> and I installed some modules like npm install mysql,npm install path, npm install routes  but there is a problem which I'm facing is most <code>middleware</code> error here is my </p>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>var express = require('express');
      var routes = require('./routes');
      var http = require('http')
      var path = require('path');
  
      //load customers route
      var customers = require('./routes/customers'); 
      var app = express();
  
      var connection  = require('express-myconnection'); 
      var mysql = require('mysql');
  
      // all environments
      app.set('port', process.env.PORT || 80);
      app.set('views', path.join(__dirname, 'views'));
      app.set('view engine', 'ejs');
      //app.use(express.favicon());
      app.use(express.logger('dev'));
      app.use(express.json());
      app.use(express.urlencoded());
      app.use(express.methodOverride());
  
      app.use(express.static(path.join(__dirname, 'public')));
  
      // development only
      if ('development' == app.get('env')) {
        app.use(express.errorHandler());
      }
  
      app.use(
  
          connection(mysql,{
  
              host: 'localhost',
              user: 'root',
              password : '',
              port : 80, //port mysql
              database:'nodejs'
  
          },'pool') //or single
  
      );                      
      app.get('/', routes.index);
      app.get('/customers', customers.list);
      app.get('/customers/add', customers.add);
      app.post('/customers/add', customers.save);
      app.get('/customers/delete/:id', customers.delete_customer);
      app.get('/customers/edit/:id', customers.edit);
      app.post('/customers/edit/:id',customers.save_edit);
      app.use(app.router);
      http.createServer(app).listen(app.get('port'), function(){
        console.log('Express server listening on port ' + app.get('port'));
      });
  </code></pre>
  
  <p>and here is other customer.js</p>
  
  <pre><code>exports.list = function(req, res){
  
    req.getConnection(function(err,connection){
  
          var query = connection.query('SELECT * FROM customer',function(err,rows)
          {
  
              if(err)
                  console.log("Error Selecting : %s ",err );
  
              res.render('customers',{page_title:"Customers - Node.js",data:rows});
  
           });
  
           //console.log(query.sql);
      });
  
  };    
  
  
       exports.add = function(req, res){
            res.render('add_customer',{page_title:"Add Customers - Node.js"});
          };
  
          exports.edit = function(req, res){
  
              var id = req.params.id;
  
              req.getConnection(function(err,connection){
  
                  var query = connection.query('SELECT * FROM customer WHERE id = ?',[id],function(err,rows)
                  {                
                      if(err)
                          console.log("Error Selecting : %s ",err );
  
                      res.render('edit_customer',{page_title:"Edit Customers - Node.js",data:rows});
  
                   });                         
              }); 
          };       
  exports.save = function(req,res){
  
      var input = JSON.parse(JSON.stringify(req.body));
  
      req.getConnection(function (err, connection) {
  
          var data = {
  
              name    : input.name,
              address : input.address,
              email   : input.email,
              phone   : input.phone             
          };
  
  
  
   var query = connection.query("INSERT INTO customer set ? ",data, function(err, rows)
          {
  
            if (err)
                console.log("Error inserting : %s ",err );
  
            res.redirect('/customers');
  
          });                               
      });
  };
  
  exports.save_edit = function(req,res){        
      var input = JSON.parse(JSON.stringify(req.body));
      var id = req.params.id;        
      req.getConnection(function (err, connection) {            
          var data = {
  
              name    : input.name,
              address : input.address,
              email   : input.email,
              phone   : input.phone 
  
  
  
   };            
          connection.query("UPDATE customer set ? WHERE id = ? ",[data,id], function(err, rows)
          {
  
            if (err)
                console.log("Error Updating : %s ",err );
  
            res.redirect('/customers');
  
          });
  
      });
  };
  
  
  exports.delete_customer = function(req,res){
  
       var id = req.params.id;
  
       req.getConnection(function (err, connection) {
  
          connection.query("DELETE FROM customer  WHERE id = ? ",[id], function(err, rows)
          {
  
               if(err)
                   console.log("Error deleting : %s ",err );
  
               res.redirect('/customers');
  
          });
  
           });
      };
  every time when i go to cmd and run the nodo app the error occur 
  
  
  
   Error: Most middleware (like logger) is no longer bundled with Express and must
      be installed separately. Please see https://github.com/senchalabs/connect#middle
      ware.
          at Function.Object.defineProperty.get (C:\Users\Tahir\Desktop\node_modules\e
      xpress\lib\express.js:89:13)
          at Object.&lt;anonymous&gt; (C:\Users\Tahir\Desktop\nodecrud-master\app.js:23:17)
          at Module._compile (module.js:456:26)
          at Object.Module._extensions..js (module.js:474:10)
          at Module.load (module.js:356:32)
          at Function.Module._load (module.js:312:12)
          at Function.Module.runMain (module.js:497:10)
          at startup (node.js:119:16)
          at node.js:906:3
  any body help to figure out where is the issue is ??
  </code></pre>