title: Express.js routing between files
body: <p>i have 3 files: server.js, bookhandler.js, books.js</p>
  
  <p>i assume that there will be requests like: /book/name, /book/type, /book etc.
  according to the first field in the url, which is book(it can also be video and magazine),i want my server.js to direct me to the bookhandler.js file with the post parameters. i only want a function here which i can validate the parameters. and if parameters are valid, i want to pass the parameters to my books.js file which i can make my post request with those valid parameters.if the first field of url is video, it should direct me to videohandler etc.</p>
  
  <p>server.js</p>
  
  <pre><code>app.use('/book', require('./bookhandler').middleware);
  </code></pre>
  
  <p>this is what i did so far, and it directs me to the bookhandler file, but i dont know how to get parameters and validate inside a function</p>
  
  <p>EDİT:</p>
  
  <blockquote>
  <pre><code>bookhandler.js
  </code></pre>
  </blockquote>
  
  <pre><code>var express = require('express');
  var app = express();
  
  module.exports.middleware = function (req, res) {
  
      var id = req.body.id;
  
      if(id.length==5) {
          app.use('/id', require('../book').middleware));
      }
  };
  </code></pre>
  
  <blockquote>
  <pre><code>book.js
  </code></pre>
  </blockquote>
  
  <pre><code>app.post('/id' , function (req, res) {
  
  });
  
  module.exports = app;
  </code></pre>