index.js
function Client(API_URL, token, opts) {
  if (!(this instanceof Client)) return new Client(API_URL, token, opts);

  if (typeof token == 'object') {
    opts = token;
    token = null;
  }

  Emitter.call(this);
  var self = this;
  opts = opts || {};
  self.cache = new LRU(opts.maxSize || 500);
  self.pending = {};

  self.root = get.bind(self, API_URL);
  self.get = get.bind(self);

  var context = self.context = superagent();

  if (token) self.header('authorization', 'Bearer ' + token);

  // TODO only set the parser for the context
  var parsers = context.request.parse;
  parsers['application/json'] = parsers['application/hyper+json'] = parseHyperJson;

  patchCrappySuperagent(context.request.Response, context.request.parse);
}
function Client(API_URL, token, opts) {
  if (!(this instanceof Client)) return new Client(API_URL, token, opts);

  if (typeof token == 'object') {
    opts = token;
    token = null;
  }

  Emitter.call(this);
  var self = this;
  opts = opts || {};
  self.cache = new LRU(opts.maxSize || 500);
  self.pending = {};

  self.root = get.bind(self, API_URL);
  self.get = get.bind(self);

  var context = self.context = superagent();

  if (token) self.header('authorization', 'Bearer ' + token);

  // TODO only set the parser for the context
  var parsers = context.request.parse;
  parsers['application/json'] = parsers['application/hyper+json'] = parseHyperJson;

  patchCrappySuperagent(context.request.Response, context.request.parse);
}
function Client ( API_URL , token , opts ) { if ( ! ( this instanceof Client ) ) return new Client ( API_URL , token , opts ) ; if ( typeof token == 'object' ) { opts = token ; token = null ; } Emitter . call ( this ) ; var self = this ; opts = opts || { } ; self . cache = new LRU ( opts . maxSize || 500 ) ; self . pending = { } ; self . root = get . bind ( self , API_URL ) ; self . get = get . bind ( self ) ; var context = self . context = superagent ( ) ; if ( token ) self . header ( 'authorization' , 'Bearer ' + token ) ; // TODO only set the parser for the context var parsers = context . request . parse ; parsers [ 'application/json' ] = parsers [ 'application/hyper+json' ] = parseHyperJson ; patchCrappySuperagent ( context . request . Response , context . request . parse ) ; }
Create a client
Create a client