workers-sdk
workers-sdk copied to clipboard
🚀 Feature Request: Support RPC (non-fetch) methods in Miniflare's Service Bindings Node.js config
Describe the solution
When defining a Service Binding for Miniflare, I can provide a Node.js implementation of a fetch handler.
It would be great if I could also provide Node.js implementations of RPC methods. Absolutely no idea how you'd do the serialization. I leave that to you 🧠 🍪.
For example:
import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";
import { Request, Response, type Miniflare } from "miniflare";
export default defineWorkersConfig({
test: {
poolOptions: {
workers: {
wrangler: { configPath: "./wrangler-workers.toml" },
miniflare: {
serviceBindings: {
MY_FETCH_BINDING: (request: Request, instance: Miniflare) => {
return new Response("Hi");
},
MY_RPC_BINDING: class MyRPCBinding {
constructor(instance: Miniflare) {
// ...
}
fetch(request: Request) {
return new Response("Hi");
}
add(a: number, b: number) {
return a + b;
}
}
},
},
},
},
},
});