Install and add to your package.json
dependencies:
npm install --save superfeedr-pshb
// Vanilla JS:
var Superfeedr = require('superfeedr-pshb').default
// ES6:
import Superfeedr from 'superfeedr-pshb'
First, create the client instance:
var superfeedr = new Superfeedr(superfeedr_user, superfeedr_password, "http://me.example.com:8080/.pshb")
The last parameter is the URL remote hubs use to connect back to you. For this to work, you must hook the PSHB request handler into your HTTP server.
http.createServer(function(req, res) {
// Call PSHB handler:
if (/^\/\.pshb/.test(req.url)) return pshbHandler(req, res)
// Do anything else you want your web server to do:
res.writeHead(404)
res.write('No PSHB!')
res.end()
}).listen(port)
Deal with it:
superfeedr.on('notification', function onNotification(notification, url) {
// Consume here...
})
Subscribe a feed, calls back cb(error, info)
Unsubscribe a feed, calls back cb(error, info)
List feeds, calls back cb(error, info)
Joins the superfeedr.list()
pages into a continuous stream of
subscription objects.
Retrieve the last entries,
calls back cb(error, result)
Configuration is accomplished using these environment variables:
SUPERFEEDR_USER
andSUPERFEEDR_PASSWORD
(credentials)- PSHB_HOST (public IP address, optionally with port) and PSHB_PORT (HTTP listen port)