title: Separating logic from Express router and still access Express functions
body: <p>I've started to write my first app with Node.js and Express, but my router file is becoming quite cluttered. In my opinion, it contains too much logic.</p>
  
  <p>I'm trying to pass a function in another file (Parent.controller.js) to the router rather than putting my logic in an anonymous function.</p>
  
  <p>So, like this: </p>
  
  <p><code>Router.post('/create-child', Parent.createChild);</code></p>
  
  <p>Rather than this:</p>
  
  <pre><code>Router.post('/create-child', function(req, res, next) {
      // do something
      // do something else
      // do even more stuff
      // this is getting messy
      // oh dear
  });
  </code></pre>
  
  <p>But I don't know how to trigger redirects, or save flash data, from the function in <code>Parent.controller.js</code>. This is because I'm not sure how to still access the <code>req</code>, <code>res</code> objects from <code>Parent.controller.js</code>. Any suggestions would be gratefully received.</p>