この質問はこの投稿に触発されましたが、私の場合はMongoIdをフィルタリングする必要があります. ルートごとに使用する必要があるため、以下のように簡単にフィルタリングすることはできますか?
app.post('/:mongoId(^[0-9a-fA-F]{24}$)', function(req, res){
// Send query based on mongoId
}
Express API documentationによると、はい、正規表現をパスとして使用できます。
正規表現も使用でき、非常に具体的な制限がある場合に役立ちます。
app.get(/^\/commits\/(\w+)(?:\.\.(\w+))?$/, function(req, res){
var from = req.params[0];
var to = req.params[1] || 'HEAD';
res.send('commit range ' + from + '..' + to);
});