I have an API route and looking to make it more dynamic

My route is defined as

app.route('/api/*/*/*')

    .get(function(req, res) {
        var entity  = req.params['0'];
        var field  = req.params['1'];
        var params = req.params['2'];
})

Is there a way to make it more dynamic? Say I only want to send 2 parameters or just call /api, or even pass 4 parameters?

Is there a way to make my route definition more open to that without explicitly defining the number of * in the route?

You can do something like below:

app.get('/api/*', function(req, res) {
   var paths = req.params[0].split('/');

   //use paths
 })

e.g for a url like '/api/a/b/c', paths will be ['a', 'b', 'c'].