simple-nats-rpc

1.2.0 • Public • Published

NATS RPC

Simple RPC via NATS

Example

server.ts

import { createServer } from 'simple-nats-rpc'

const functions = {
  add: (a, b) => a + b,
  subtract: (a, b) => b - a
}

createServer({ payload: Payload.JSON }, functions)

client.ts

import { createClient } from 'simple-nats-rpc'

const client = await createClient({ payload: Payload.JSON })

const result = await client.request('add', [1, 2], { timeout: 1000 })
// => 3

const result2 = await client.request('subtract', [5, 10])
// => 5

Readme

Keywords

none

Package Sidebar

Install

npm i simple-nats-rpc

Weekly Downloads

0

Version

1.2.0

License

MIT

Unpacked Size

10.1 kB

Total Files

11

Last publish

Collaborators

  • angryunicorn