wskit

yarn add wskit

Usage no npm install needed!

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

README

WSKIT

Install

yarn add wskit

Server Usage

const { WsServer, ActionHandler } = require('wskit')

class EchoActionHandler extends ActionHandler {
  static get method() { return 'echo' }

  async run(params) {
    return `ECHO ${params.message}`
  }
}

WsServer.start().then((server) => {
  server.registerActionHandler(EchoActionHandler)
})

Client Usage

const { WsClient } = require('wskit')

WsClient.start().then((client) => {
  client.action('echo', { message: 'Hello World' }).then((response) => {
    console.log(response.params.message) // returns 'ECHO Hello world'
  })
})