title: Node.js Express export routes for organization?
body: <p>Utilizing express.Router() for API calls to/from our application:</p>
  
  <pre><code>var express = require('express');
  var app     = express();
  var router  = express.Router();
  </code></pre>
  
  <p><code>router.use</code> console.logs before every API call:</p>
  
  <pre><code>router.use(function(req, res, next) { // run for any &amp; all requests
      console.log("Connection to the API.."); // set up logging for every API call
      next(); // ..to the next routes from here..
  });
  </code></pre>
  
  <p>How do we export our routes to <code>folder/routes.js</code> and access them from our main <strong>app.js</strong>, where they are currently located:</p>
  
  <pre><code>router.route('/This') // on routes for /This
      // post a new This (accessed by POST @ http://localhost:8888/api/v1/This)
      .post(function(req, res) {
          // do stuff
      });
  
  router.route('/That') // on routes for /That
      // post a new That (accessed by POST @ http://localhost:8888/api/v1/That)
      .post(function(req, res) {
          // do stuff
      });
  </code></pre>
  
  <p>...when we prefix every route with:</p>
  
  <pre><code>app.use('/api/v1', router); // all of the API routes are prefixed with '/api' version '/v1'
  </code></pre>