unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.83k stars 491 forks source link

Unable to override dynamic param route #2694

Open yassilah opened 2 weeks ago

yassilah commented 2 weeks ago

Environment


Reproduction

https://stackblitz.com/edit/github-xqvnbx?file=server%2Froutes%2Findex.ts

Describe the bug

What I am trying to achieve is the following:

The use case is to create a simple CRUD API for each table of a database, e.g.:

while preserving the ability to override a specific endpoint for a table that requires specific handling, e.g.:

In doing so, I would expect PATCH /api/bar/1 to still work but it seems that Nitro will discard any /api/bar/* endpoints after creating that file.

Additional context

No response

Logs

No response

pi0 commented 2 weeks ago

Hi. sadly this is a limitation of route matcher algorithm in nitro v2 (radix3). in nitro v3, we use new implementation (rou3) which should handle this well. i will try to test it in a local app but you can also directly test nitro v3 via nightly channel.