title: How to pass a parameter to middleware function in Express JS?
body: <pre><code>// state edit route
  app.get("/map/:symbol/edit", isLoggedIn, function(req, res){
    State.findOne({symbol: req.params.symbol}, function(err, state){
      if(err){
        console.log(err);
      } else
      {
        res.render("edit", {state: state});
      }
    });
  });
  </code></pre>
  
  <p>In the above code snippet, <strong>isLoggedIn</strong> is the middleware function to check for authentication. Its definition is given below:</p>
  
  <pre><code>// middleware function
  function isLoggedIn(req, res, next){
    if(req.isAuthenticated()){
      return next();
    }
    res.redirect("/admin");
  }
  </code></pre>
  
  <p>So, the question is, how to pass a parameter like a string, an integer or a path variable to the middleware function so that it can be used in the routing url ?</p>