Skip to content

Latest commit

 

History

History
37 lines (26 loc) · 1.13 KB

README.md

File metadata and controls

37 lines (26 loc) · 1.13 KB

web-sub

JavaScript Style Guide npm version

Simple WebSub client for Node.js. It provides publish and subscribe methods.

Installation

Also, you'll need to install an adapter. For the moment the only available adapter is web-sub-kafka-adapter.

This package could be extended to use any other apdater such as RabbitMQ, SQS, ActiveMQ, etc.

npm install --save @wedevelop/web-sub @wedevelop/web-sub-kafka-adapter

Quick start

const WebSubClient = require('@wedevelop/web-sub')
const KafkaAdapter = require('@wedevelop/web-sub-kafka-adapter')

const topic = 'demo'
const webSubClient = new WebSubClient(new KafkaAdapter())

webSubClient.publish([{ topic, messages: [new Date()] }])
  .then(console.log)
  .catch(console.error)

webSubClient.subscribe(topic, (err, data) => {
  if (err) {
    console.error(err)
  } else {
    console.log(data)
  }
})