nksaraf / vinxi

The Full Stack JavaScript SDK
https://vinxi.vercel.app
MIT License
1.91k stars 77 forks source link

`event.context.params` is empty when using `apiRouter` #242

Closed alessandrojcm closed 6 months ago

alessandrojcm commented 7 months ago

Hi tehre, I am playing around with the apiRouter from @vinxi/router. I've noticed that the event.context.params from the event passed to the API route handlers is empty, hence making functions like getRouterParam fail. I know that the params are passed as a second argument to defineEventHandler but I believe it would be good to pass them as pass of the event object to make it more inline with H3 (also making H3 code directly portable, which is my case).

Reading the API Handler code, I believe just adding the params object to event.context would be sufficient, I may be missing something but if I am not I would be happy to make that PR.

nksaraf commented 7 months ago

I think you're right, we should just do that. Would love to merge that PR once its done