Express routes parameter conditions

Expanding on Marius’s answer, you can provide the regex AND the parameter name:

app.get('/:id(\\d+)/', function (req, res){
  // req.params.id is now defined here for you
});

Leave a Comment