expressjs / expressjs/express

feat: Support typed params in routes

Open
#2,756 6 comments 0 reactions 0 assignees View on GitHub
5.x discuss enhancement module:router
Dominant language
JavaScript
Stars
69.5k
Forks
25k
Avg merge
4d 20h
Merged PRs (30d)
9

Description

I mean, do something like:

``` js
app.route('/:an_id{number}');
app.route('/:another_id{string}')
```

which is roughly equivalent to use regex in each case, but the shorthand above is clearer and allows `req.params` to properly type the params, fi: `req.params.an_id` would be a number instead of a string.

Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.