Deno implementation of JSON-RPC Specification. Currently support Spec 2.0.
Import the module in your TypeScript file.
import {
createRPC,
RPC,
} from "https://deno.land/x/deno_json_rpc/src/rpc_two.ts";
// vscode_io is an implementation of VSCode-style I/O.
import {
createVSCodeIO,
} from "https://deno.land/x/deno_json_rpc/src/vscode_io.ts";
// Create your RPC actor
const rpc: RPC = createRPC(createVSCodeIO(Deno.stdin, Deno.stdout));
// add a listener for methods you will receive (requests/notifications)
rpc.onRequest("CalculateOneAndOne", (_params: unknown) => {
// Will automatically respond, assuming the return as the result
return 1 + 1;
});
// Start the service
rpc.start();
Documentation is available on doc.deno.land.
Project under the MIT License, read LICENSE for more information.