doseofted / prim-rpc

Easy-to-understand, type-safe, transport-agnostic RPC/IPC for JavaScript, supporting callbacks, batching, file handling, custom serialization, and more.
https://prim.doseofted.me
Apache License 2.0
98 stars 1 forks source link

Extended Options for Fetch API Plugin #57

Closed doseofted closed 1 year ago

doseofted commented 1 year ago

The Fetch API doesn't have the same options available in many server frameworks, like connect middleware or plugins. Instead, changes are made directly to the Request/Response objects. This PR will add two new options, "preprocess" to modify the Request before being given to Prim+RPC and "postprocess" to manipulate the Response created by Prim+RPC.

This will allow headers to be set (specifically CORS and CSP) without explicitly providing limited "options" for the plugin.

This also adds support for using Fetch with Node using @whatwg-node/server (previously didn't work due to usage of instanceof on ponyfilled objects).

changeset-bot[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: 77450a23858813a5ab155f3d80b507f76dcae4eb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages | Name | Type | | ------------------------------------- | ----- | | @doseofted/prim-rpc-plugins | Patch | | @doseofted/prim-documentation-website | Patch | | @doseofted/prim-example-server | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
prim-rpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 28, 2023 10:00pm