JSPM

node-ws-captp

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q30411F
  • License ISC

A module for exposing a CapTP interface over websockets.

Package Exports

  • node-ws-captp

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-ws-captp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Node Websocket CapTP

A node.js module for exposing and connecting with CapTP over Websockets.

This builds on the module ws, which uses the node Socket API, and so this should only work in node, but if your bundler polyfills node APIs like browserify does, you may find it works, as it does in the browser example.

Installation

npm i node-ws-captp -S or yarn add node-ws-captp.

Usage

Complete usage for both client and server can be observed in a single very simple test:

const { createServer, createClient } = require('node-ws-captp');

test('basic connection', async (t) => {
  const greeting = 'Hello, world!';

  const bootstrap  = {
    greet: async () => greeting,
  };

  const killServer = createServer(bootstrap, 8088);

  const { E, getBootstrap, abort } = createClient('ws://localhost:8088');

  const value = await E(getBootstrap()).greet();
  t.equals(value, greeting, 'Returned greeting over server');
  abort();
  killServer();
  t.end();
});