A WebSub Hub implementation in Node.js
- Node: >= 8.0
- Lead Maintainer: Dustin Deus
- Highly performant: A single node can handle thousands of subscriptions.
- Scalable: Scale the hub in minutes. We choose monogdb as distributed storage.
- Efficient: Only distribute delta updates.
- Websocket: Use websockets to get updates in realtime.
- Standardized We're trying to be compliant with the W3C WebSub specification.
- Developer friendly Provide an easy interface to configure and use the hub.
$ docker run -d -p 27017:27017 -p 28017:28017 -e AUTH=no tutum/mongodb
$ npm i -g webpub-server
$ websub-hub -l info -m mongodb://localhost:27017/hub
$ node examples\server.js
$ node examples\feed.js
$ node examples\callback.js
As soon as you want to subscribe to a topic you can initiate a subscription request. The subscriber has to verify that action as mentioned above.
const Subscriber = require('websub-hub').subscriber
const s = new Subscriber({ hubUrl: 'http://127.0.0.1:3000' })
s.subscribe({
topic: 'http://127.0.0.1:6000',
callbackUrl: 'http://127.0.0.1:5000'
}).then((response) => {})
const Subscriber = require('websub-hub').subscriber
const s = new Subscriber({ hubUrl: 'http://127.0.0.1:3000' })
s.unsubscribe({
topic: 'http://127.0.0.1:6000',
callbackUrl: 'http://127.0.0.1:5000'
}).then((response) => {})
const Publisher = require('websub-hub').publisher
const p = new Publisher({ hubUrl: 'http://127.0.0.1:3000' })
p.publish('http://127.0.0.1:6000').then((response) => {})
$ npm run test