Allow for multiple parameter names in router.param()
- Dominant language
- JavaScript
- Stars
- 69.5k
- Forks
- 25k
- Avg merge
- 4d 20h
- Merged PRs (30d)
- 9
Description
Hi,
I just found out about router.param() and immediately started using it in my code. It makes checks based on parameters so darn clean :) Really good job on the inventor of that idea!
While using it i found myself wondering with a url like: "/:year/:month/:day". How can you make a router.param(...) function that is called when exactly those 3 arguments have been provided in the url?
Perhaps it is possible, but i haven't seen a way in the documentation.
Since router.param() works on parameter names, i would suggest a feature like the following to allow for an implementation of the above to be possible in router.param().
```
router.param(['year', 'month', 'day'], (req, res, next, obj) => {
obj.year; // contain the year value
obj.month; // contain the month value
obj.day; // contain the day value
});
```
I would say that the first array in which the params are provided as string must be the exact order in which they would occur in the app.get('/:year/:month/:day' ...) function;
Is there any technical (or practical) reason why a feature like this wouldn't be possible?
What are your thoughts on this?
Best regards,
Mark
Contributor guide
Assessment
This issue has not been assessed yet.