-
Notifications
You must be signed in to change notification settings - Fork 295
feat(handler): new defineJsonRpcHandler
#1180
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| } | ||
|
|
||
| const { id, method, params } = req; | ||
| const handler = methods[method]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we might need some builtin protection against proto access
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with b25d034 I've implemented a simple safeguard for it.
Let me know if I'm on the right track, as I do realize this is a topic which I'm weak in knowledge :/
Deploying h3dev with
|
| Latest commit: |
4d0d8c0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d4d2748b.h3dev.pages.dev |
| Branch Preview URL: | https://feat-json-rpc-handler.h3dev.pages.dev |
jsonRpcHandlerdefineJsonRpcHandler
|
Hi dear @sandros94 This PR is under my radar (and important!) but have to delay for more testing. In meantime you don't need to keep it updated ❤️ |
Absolutely no problem, I also imagine that we all took some time off for the summer and should focus on more important things first, this is a long term one. This feature is also easy to implement in downstream projects, so no rush. The reason why I kept updating it for a bit was because while testing it with some Json RPC clients (mainly MCP-related ones) I've found a couple of issues and DX improvements, but now it is complete for what I know atm |
An experimental handler to support the JSON RPC spec.
Usage
you define it like a normal handler, but with the added
paramsas its first callback argument:then you call it with a valid body, for example:
{ "jsonrpc": "2.0", "id": 1, "method": "echo", "params": "Hello World", }and you'll receive a json-rpc compatible response:
{ "jsonrpc": "2.0", "id": 1, // Same id from the request "result": "Recieved `Hello World` on path `/rpc`", }it also support client-to-server notifications by simply omitting the
idkey, this will result in the server responding a202Personal considerations and future expansion