title: abstract (req, res, next) in node
body: <p>Say I have a route:</p>
  
  <pre><code>app.get(abc, (req, res, next) =&gt; {
      if (req.params.ID === undefined) { 
          res.status(400); 
          res.end(); 
      }
      next();
  });
  </code></pre>
  
  <p>I am wondering if this would work the same if I abstracted the if statement to another file like this: </p>
  
  <pre><code>let undefinedID = (req, res, next) =&gt; {
      if (req.params.ID === undefined) {
          res.status(400); 
          res.end();
      }
      next();
  }
  
  module.exports = {undefinedID};
  </code></pre>
  
  <p>and then called the function inside my route:</p>
  
  <pre><code>const reqConditionals = require('path/to/fxn');
  
  app.get(abc, () =&gt; {
      reqConditionals.undefinedID();
  });
  </code></pre>
  
  <p>The reason I want to do this is because I have a lot routes with similar request conditionals and responses and want to start refactoring it. So, if I do it this way, would it work the same?</p>