node package manager
We need your input. Help make JavaScript better: Take the 2017 JavaScript Ecosystem survey »

livefyre-subscriptions

livefyre-subscriptions

A JavaScript library for managing Subscriptions in Livefyre's Personalized News Stream service.

Usage

This module is intended to work in both node.js and the browser (via browserify). Run make dist to put the browser bundle in dist/.

Use as a CLI (e.g. if you npm install -g livefyre-subscriptions):

CLI

livefyre-subscriptions --auth=$LFTOKEN
[
  {
    "to": "urn:livefyre:demo.fyre.co:site=362588:topic=mlb",
    "type": "personalStream",
    "by": "urn:livefyre:demo.fyre.co:user=system",
    "createdAt": 1406886370
  }
]

You can even pipe to something like jq:

livefyre-subscriptions --auth=$LFTOKEN | jq .[]

JavaScript

var subscriptions = require('livefyre-subscriptions');

API

The main export is an object.

.forUser(user)

Manage a user's subscriptions.

var subscriptions = require('livefyre-subscriptions');
var benSubscriptions = subscriptions.forUser({
    userId: 'ben',
    network: 'go.fyre.co',
    lftoken: 'optional. will use LFTOKEN env variable by default'
});
// or... 
var benSubscriptions = subscriptions.forUser('ben@go.fyre.co');

When you have a user's subscriptions, there are a few methods you can call that will perform operations using Livefyre's HTTP APIs. Each of these methods returns a promise.

Get subscriptions

benSubscriptions.get().then(function (data) {
    console.log(data.subscriptions);
})

Create a new subscription

var newSubscription = {
    to: 'urn:livefyre:demo.fyre.co:site=362588:topic=mlb',
    type: 'personalStream'
};
benSubscriptions.create(newSubscription).then(
    function (data) {
        console.log('success');
    },
    function (e) {
        console.error(e);
    }
);

make commands

  • make build - will npm install and bower install
  • make dist - will use r.js optimizer to compile the source, UMD wrap, and place that and source maps in dist/
  • make clean
  • make server - serve the repo over http
  • make deploy [env={*prod,uat,qa}] - Deploy to lfcdn, optionally specifying a bucket env