Repository navigation
add fetch adapter - #1852
add fetch adapter#1852
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Cc @esamattis |
There was a problem hiding this comment.
Looks really good!
A few pieces I'd want to improve:
- Add follow-up ticket to invert
resolveHTTPResponseso that modern handling is the default and old handler - Docs for the adapter
- Add example project to the list of example projects
- Simplify example project to be just a mutation and a query?
| "include": ["src", "test"], | ||
| "compilerOptions": { | ||
| "lib": ["ES2020", "DOM"], | ||
| "lib": ["ES2020", "DOM", "DOM.Iterable"], |
There was a problem hiding this comment.
Do we need this when we are targeting node 14? 🤔
There was a problem hiding this comment.
Yes, it is needed to add Symbol.iterator to the Headers type so we can use Object.fromEntries:
Note that Node does not implement the Fetch spec.
Co-authored-by: Alex Johansson <[email protected]>
jlalmes
left a comment
There was a problem hiding this comment.
Not very familiar with Cloudflare Workers, but LGTM! ✅
|
Thanks for reviewing! As a side note, this is much more than just CF Workers. Deno (Deploy), SvelteKit, Astro, Next.js middleware, Remix, and others are also using the Fetch API. |
|
This pull request has been locked because it had no new activity for 30 days. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |
closes #1374
part of #1597
Adds a Fetch API adapter to
@trpc/server.Also adds a Cloudflare Workers example. Right now tests and the actual router are just copied from the Express example. Preferably both examples would use the same files so an update to the code only has to happen in one place, but not sure how to make that happen unless I move the files out of the individual example directories.
Let me know if I should add myself as a codeowner.
cc @icflorescu who may be interested as the author of trpc-sveltekit (would love a review if you have time)
also cc @esamattis as the author of trpc-fetch-api-adapter (would also love a review)
Thanks to both of you for your packages! Took a lot of inspiration from them.