title: Nodejs, Express. Is there a way to store/get what POST params are required in an endpoint to show to the client?
body: <p>I'm writing some test page to debug my API and expose it neatly.</p>
  
  <p>Using Express <a href="http://expressjs.com/api.html#app.routes" rel="nofollow">app.routes</a> I can get a neat list of all the endpoints my application implements, so I can show to the users the list of possible POST requests.</p>
  
  <p>However, most of them require some POST parameters, which the server obtains from the requests in this way, for example (/api/ping requires a "ping" POST parameter):</p>
  
  <pre><code>app.post("/api/ping", function(req, res) //
  {
      var ping = req.param('ping');
  
      if( ping ) {    
          res.out.message = "Pong";
      } else {
          res.out.message = "Ping missing";
      }
  
      return exports.respond(res);
  });
  </code></pre>
  
  <p>I noticed that app.routes has a "keys" and a "params" keys in the endpoints list, but I think this seems to be used only for parameters that are in the path (for example "userid" as parameter when someone requests for the "/user/:userid" path). I believe express calls these stored parameters "pre-conditions".</p>
  
  <p>Is there any way to add preconditions like these to express app for POST parameters so that they are also shown in the app.routes object and I can display neatly which parameters are required for which endpoint?</p>