@itchio/butlerd
v15.0.0
Published
Node.js library for butlerd, the butler daemon
Readme
butlerd for node.js
The butlerd package handles:
- launching butler in daemon mode
- connecting to it
- sending requests and notifications to it
- receiving results and notifications from it
- terminating it
It implements the JSON-RPC 2.0 Specification over TCP, excluding batch requests (section 6), allowing requests and replies in both directions.
Usage
import { Instance, Client } from "@itchio/butlerd";
import * as messages from "./butlerd/messages"; // generated with generous
// Start butler daemon
const instance = new Instance({
butlerExecutable: "/path/to/butler",
});
// Connect a client
const client = new Client(await instance.getEndpoint());
// Make a request
const result = await client.call(messages.VersionGet, {});
console.log(result.version);
// Shut down
instance.cancel();
await instance.promise();For more complete examples including handling notifications and requests, see the tests.
Generating TypeScript Definitions
This repository does not include request or notification definitions for butler's API. You can generate typed message definitions using the generous tool included in the butler repository:
git clone https://github.com/itchio/butler
cd butler
go run ./butlerd/generous ts butlerd/messages.tsThis generates TypeScript files with typed request and notification creators that work with this package's Client.call() method.
License
node-butlerd is released under the MIT license, see the LICENSE file.
