The above route will never get executed since we have a route inside CRUD with a param matching GET /cars/:id. So in /cars/featured the featured path will be read as an :id param.
This forces someone who extends endpoints to use not-so-elegant solutions (like putting CRUD endpoints inside a /crud/ path, etc). A nice solution would be enabling a way to force a route only be registered by typescript-rest after all other routes got registered, which prevent this issue.
I also have this problem right now.
It would be nice to have some kind of decorator or perhaps a startup option.
Saying that it should match the full url or else go into the :id path.
As of today you can extend endpoints from a "base" class, which is useful for CRUDs like this example:
And then I can use it on my other endpoints as follows:
But here comes the issue (related to #96): If I try to create another endpoint specific to
CarsEndpoint
, e.g.:/cars/featured
:The above route will never get executed since we have a route inside
CRUD
with a param matchingGET /cars/:id
. So in/cars/featured
thefeatured
path will be read as an:id
param.This forces someone who extends endpoints to use not-so-elegant solutions (like putting CRUD endpoints inside a
/crud/
path, etc). A nice solution would be enabling a way to force a route only be registered by typescript-rest after all other routes got registered, which prevent this issue.So by doing this:
We make sure those routes will only execute after all other routes are tried for matching.
What do you think?