X Tutup
Skip to content

itchio/node-butlerd

Repository files navigation

butlerd for node.js

MIT licensed Test Available on npm

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.

Installation

npm install @itchio/butlerd

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.ts

This 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.

About

🐦 Node.js client for butlerd, the butler daemon

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

X Tutup