1.0.0 • Published 5 years ago

@wedevelop/web-sub v1.0.0

Weekly downloads
6
License
ISC
Repository
github
Last release
5 years ago

web-sub

JavaScript Style Guide

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