Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tennashi/deno-jsonrpc2
A JSON-RPC 2.0 library for Deno
https://github.com/tennashi/deno-jsonrpc2
Last synced: about 1 month ago
JSON representation
A JSON-RPC 2.0 library for Deno
- Host: GitHub
- URL: https://github.com/tennashi/deno-jsonrpc2
- Owner: tennashi
- License: mit
- Created: 2022-02-19T08:19:48.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-11T22:12:33.000Z (almost 2 years ago)
- Last Synced: 2023-08-08T20:45:11.773Z (over 1 year ago)
- Language: TypeScript
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jsonrpc2
A JSON-RPC 2.0 library for Deno
## Usage
```ts
import * as io from "https://deno.land/std/io/mod.ts";
import {
Connection,
NotificationMessage,
NotificationRouter,
RequestMessage,
RequestRouter,
ResponseMessage,
VSCodeStream,
} from "https://deno.land/x/jsonrpc2/mod.ts";const rr = new RequestRouter();
rr.registerFn("hello", (req: RequestMessage): Promise => {
const res: ResponseMessage = {
jsonrpc: "2.0",
id: req.id,
result: "hello",
};
return Promise.resolve(res);
});const nr = new NotificationRouter();
nr.registerFn("hello", (notif: NotificationMessage): Promise => {
console.log(notif);
return Promise.resolve();
});const r = new io.Buffer();
const w = new io.Buffer();
const stream = new VSCodeStream(r, w);
const conn = new Connection(stream, rr);
conn.listen();conn.close();
```## Acknowledgements
I used the following code as a reference.* https://github.com/lambdalisue/deno-msgpack-rpc
* https://github.com/hrsh7th/deno-json-rpc
* https://pkg.go.dev/golang.org/x/tools/internal/jsonrpc2