arpeecee

Simple duplex stream based binary RPC module for well defined services and methods

Usage no npm install needed!

<script type="module">
  import arpeecee from 'https://cdn.skypack.dev/arpeecee';
</script>

README

arpeecee

Simple duplex stream based binary RPC module for well defined services and methods

npm install arpeecee

Usage

const RPC = require('arpeecee')

const stream = new RPC({
  errorEncoding: someAbstractEncoding
})

// define a method
const aMethod = stream.defineService({ id: 1 })
  .defineMethod({
    id: 1,
    requestEncoding: someAbstractEncoding,
    responseEncoding: someAbstractEncoding,
    async onrequest (value) {
      console.log('decoded request', value)
      // return decoded response
    }
  })

// call the method on the other side
const decodedResponse = await aMethod.request(decodedValue)

stream.pipe(someStream).pipe(stream)

LICENSE

MIT