Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Feature Request: Support RPC (non-fetch) methods in Miniflare's Service Bindings Node.js config #6966

Open
GregBrimble opened this issue Oct 14, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@GregBrimble
Copy link
Member

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;
							}
						}
					},
				},
			},
		},
	},
});
@GregBrimble GregBrimble added the enhancement New feature or request label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant