Separating Routes and Middleware into Files (in Express.js)
<p>I'd like to separate <strong>routes</strong> and <strong>middleware</strong> out of my main <strong>app.coffee</strong>-file. (I'm using <strong>Express.js</strong>.)</p>

<p>This file has grown <em>extensively</em> and is not easy to skim anymore.</p>

<p>How can I put those into separate files so they are still aware of each other?</p>

<p>Example of route that <strong>uses</strong> middleware:</p>

<pre><code>app.post '/signup', signup.inputsOK, signup.userIsNew, signup.createUser, allowUser, (req, res) -&gt;
  res.redirect '/'
</code></pre>

<p>Every middleware function should be available for each route and each route should be available in the main app.coffee-file!</p>

<p>Thanks for ideas!</p>