subhub is a simple node.js interface for subscribing to a pubsubhubbub hub. subhub includes a library for integrating into your existing node.js servers, as well as a simple command line tool for debugging hub output.
subhub provides a simple library for integrating a subhub connection into your existing node.js, connect, or express http servers.
$ npm install subhub
to use the api, you simply need to configure a subhub instance, tell your server to use it's request handler, and create a subscription. a simple example of this follows.
http = require('http')subhub = require('subhub')server = do http.createServer# configure a subhub instancefirehose = new subhub'url': '''subscription':'hub.mode': 'subscribe''hub.verify': 'sync''hub.callback': '''hub.topic': ''# set up the http handlersserver.on 'request', firehose.requestListenerserver.listen 8000# 'data' fires for each document sent by the hubfirehose.on 'data', (doc) ->console.log doc# send a subscription request# (once subscribed, the hub will begin sending data)do firehose.subscribe
a command line client is provided which simply creates up a subscription and writes all incoming hub entries to stdout. this is the quickest way to see all the data being sent by the hub. the client uses nconf, allowing you to configure the subscription through command line arguments, environment variables, or flat files (with that order.
$ npm install -g subhub
$ subhub --helpUsage: subhubArguments:-h, --help Help. You're looking at it-c, --config Config file [./config.json]--http.port Port to run the http server on --hub.url The url of the hub you are subscribing to--hub.subscription.mode Request mode [subscribe]--hub.subscription.verify Hub verification mode [sync]--hub.subscription.callback Your callback URL the hub will send data to--hub.subscription.topic The feed url of the topic you are subscribing to$ subhub --hub.url= --hub.subscription.topic= --hub.subscription.callback=[stream of messages]