Closed meeroslav closed 3 years ago
Type checked URL router: https://ja.nsommer.dk/articles/type-checked-url-router.html
I think this is worth exploring. We also would need to get the path and params info with the internal matcher
The path type checking, unfortunately, requires Template Literal Types which landed in TypeScript v4.1. We can park this for later. But internal matcher is still possible.
pathToRegexp
provides nice functionality for parsing routes, but also includes a lot of functionality we do not use or need.Simple built-in function could reduce footprint further. Take a look at following:
With these few common patterns we can describe every route matcher Regexp