superfeedr-hapi
This is a re-usable Hapi plugin for Superfeedr. It implements a small subset of PubSubHubbub API calls to allow the following:
- subscribe
- unsubscribe
- handle notifications
Usage
var superfeedr = require('hapi-superfeedr');
var superfeedrOptions = {
login: 'demo',
password: 'ee72118e8a2a7939361fe48c478b9135',
webhooks: {
host: '14ab6330636c.b.passageway.io',
base: '/superfeedr',
scheme: 'http',
port: 80
}
}
server.pack.register({plugin: superfeedr, options: superfeedrOptions}, function(err) {
if (err) {
console.error('Failed to load a plugin:', err);
}
});
```javascript
Later, anywhere your app you can invoke the following:
```javascript
server.plugins.superfeedr.on('notification', function(feed_id, payload, url, request) {
});
server.plugins.superfeedr.subscribe(url, id, {retrieve: true, format: 'atom', 'secret': 'xxxx'}, function(error, body) {
});
server.plugins.superfeedr.unsubscribe(url, id, function(error) {
});
Warning: This is my very very first hapi project, so there are likely imperfections and even bugs. Please use with caution and feel free to fork and fix/improve. It also only implements a very small subset of Superfeedr features.