@vmisztvl/tiny-rpc
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

tiny-rpc

A node package that allows rpc over websockets and pushing messages from server to client.

  • Focused on simplicity.
  • Promise api.
  • Written in typescript.

Package repo

Full example

Server

import { RpcServer } from '@vmisztvl/tiny-rpc';

const rpc = new RpcServer(server, '/rpc');

rpc.registerHandler('getTime', () => Date.now());

rpc.onNewClient = (client) => client.post('messages', 'Hello client!');

Client

import { RpcClient } from '@vmisztvl/tiny-rpc';

const rpc = new RpcClient('/rpc');

rpc.subscribe('messages', addMessage);

button.onclick = async () => {
  const data = await rpc.call('getTime');
  console.log(data);
};

Please do submit feature requests / bugs / questions / suggestions.

Readme

Keywords

Package Sidebar

Install

npm i @vmisztvl/tiny-rpc

Weekly Downloads

1

Version

0.3.1

License

ISC

Unpacked Size

13.4 kB

Total Files

14

Last publish

Collaborators

  • vmisztvl