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.58k stars 480 forks source link

`$fetch` type-safety for calling other Nitro endpoints #646

Closed manniL closed 2 months ago

manniL commented 1 year ago

Describe the feature

Hey! It might be a far fetch, but sometimes, one nitro endpoint calls another one via $fetch (e.g. a Nuxt server route calling an API endpoint). Would it be possible to achieve $fetch type-support here too?

Opening in this repo instead of the nuxt framework repo because it could be supported for all nitro setups.

https://stackblitz.com/edit/unjsnitroissues646?file=routes%2Findex.ts,routes%2Fabout.ts

image

Additional information

danielroe commented 1 year ago

This should work already. Would you give an example of it not working?

manniL commented 1 year ago

Yes, sure! StackBlitz attached, tested locally.

image
pi0 commented 2 months ago

It seems to be working in latest nitro

image

please feel free to reopen if can reproduce.