superfeedr-pshb

0.0.0 • Public • Published

Installing

Install and add to your package.json dependencies:

npm install --save superfeedr-pshb

Usage

// Vanilla JS:
var Superfeedr = require('superfeedr-pshb').default
 
// ES6:
import Superfeedr from 'superfeedr-pshb'

Initialize and hook callback handler

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)

Event 'notification'

Deal with it:

superfeedr.on('notification', function onNotification(notification, url) {
  // Consume here...
})

superfeedr.subscribe(url, cb)

Subscribe a feed, calls back cb(error, info)

superfeedr.unsubscribe(url, cb)

Unsubscribe a feed, calls back cb(error, info)

superfeedr.list(opts, cb)

List feeds, calls back cb(error, info)

superfeedr.streamSubscriptions(opts)

Joins the superfeedr.list() pages into a continuous stream of subscription objects.

superfeedr.retrieve(qs, cb)

Retrieve the last entries, calls back cb(error, result)

Running the examples and tests

Configuration is accomplished using these environment variables:

  • SUPERFEEDR_USER and SUPERFEEDR_PASSWORD (credentials)
  • PSHB_HOST (public IP address, optionally with port) and PSHB_PORT (HTTP listen port)

Readme

Keywords

Package Sidebar

Install

npm i superfeedr-pshb

Weekly Downloads

1

Version

0.0.0

License

MIT

Last publish

Collaborators

  • astro
  • julien51