Skip to content

WeDevelop-ARG/web-sub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)
  }
})

Releases

No releases published

Packages

No packages published