Skip to main content
Deno 2 is finally here 🎉️
Learn more

deno-json-rpc

Deno implementation of JSON-RPC Specification. Currently support Spec 2.0.

Usage

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

Documentation is available on doc.deno.land.

License

Project under the MIT License, read LICENSE for more information.