title: Rest with Express.js nested router
body: <p>Suppose I want to have REST endpoints which look roughly like this:</p>
  
  <pre><code>/user/
  /user/user_id 
  
  /user/user_id/items/
  /user/user_id/items/item_id
  </code></pre>
  
  <p>CRUD on each if makes sense. For example, /user POST creates a new user, GET fetches all users. /user/<em>user_id</em> GET fetches just that one user.</p>
  
  <p>Items are user specific so I put them under <em>user_id</em>, which is a particular user.</p>
  
  <p>Now to make Express routing modular I made a few router instances. There is a router for user, and a router for the item.</p>
  
  <pre><code>var userRouter = require('express').Router();
  userRouter.route('/')
    .get(function() {})
    .post(function() {})
  userRouter.route('/:user_id')
    .get(function() {})
  
  var itemRouter = require('express').Router();
  itemRouter.route('/')
    .get(function() {})
    .post(function() {})
  itemRouter.route('/:item_id')
    .get(function() {})
  
  app.use('/users', userRouter);
  
  // Now how to add the next router?
  // app.use('/users/', itemRouter);
  </code></pre>
  
  <p>URL to <code>item</code> is descendents of the URL hierarchy of the <code>user</code>. Now how do I get URL with <code>/users</code> whatever to userRouter but the more specific route of <code>/user/*user_id*/items/</code> to the itemRouter? And also, I would like user_id to be accessible to itemRouter as well, if possible.</p>