index.js
function Fbbot(options)
{
  if (!(this instanceof Fbbot)) return new Fbbot(options);

  /**
   * Custom options per instance
   * @type {object}
   */
  this.options = merge(Fbbot.defaults, options || {});

  /**
   * Store credentials
   * @type {object}
   */
  this.credentials =
  {
    // keep simple naming for internal reference
    token : this.options.pageAccessToken || this.options.token,
    secret: this.options.verifyToken || this.options.secret
  };

  if (!this.credentials.token || !this.credentials.secret)
  {
    throw new Error('Both `token` (pageAccessToken) and `secret` (verifyToken) are required');
  }

  // compose apiUrl
  this.options.apiUrl += this.credentials.token;

  /**
   * expose logger
   * @type {object}
   */
  this.logger = options.logger || bole(options.name || 'fbbot');

  /**
   * middleware storage (per event)
   * @type {object}
   * @private
   */
  this._stack = {};

  /**
   * lock-in public methods
   * wrap `_handler` with agnostic to accommodate different http servers
   * @type {function}
   */
  this.requestHandler = agnostic(this._handler.bind(this));

  // attach lifecycle filters
  inMiddleware(this);
  outMiddleware(this);

  /**
   * create incoming traverse paths
   * @type {Traverse}
   * @private
   */
  this._incoming = new Traverse(inTraverse.steps, {
    entry     : middleware.entryPoint,
    middleware: inTraverse.middleware.bind(this),
    emitter   : inTraverse.emitter.bind(this),
    prefix    : inTraverse.prefix
  });
  // wrap linkParent method
  this._incoming.linkParent = inTraverse.linkParent.bind(null, this._incoming.linkParent);

  /**
   * create outgoing traverse paths
   * @type {Traverse}
   * @private
   */
  this._outgoing = new Traverse(outTraverse.steps, {
    middleware: outTraverse.middleware.bind(this),
    emitter   : outTraverse.emitter.bind(this),
    prefix    : outTraverse.prefix
  });
  // wrap linkParent method
  this._outgoing.linkParent = outTraverse.linkParent.bind(null, this._outgoing.linkParent);
}
function Fbbot(options)
{
  if (!(this instanceof Fbbot)) return new Fbbot(options);

  /**
   * Custom options per instance
   * @type {object}
   */
  this.options = merge(Fbbot.defaults, options || {});

  /**
   * Store credentials
   * @type {object}
   */
  this.credentials =
  {
    // keep simple naming for internal reference
    token : this.options.pageAccessToken || this.options.token,
    secret: this.options.verifyToken || this.options.secret
  };

  if (!this.credentials.token || !this.credentials.secret)
  {
    throw new Error('Both `token` (pageAccessToken) and `secret` (verifyToken) are required');
  }

  // compose apiUrl
  this.options.apiUrl += this.credentials.token;

  /**
   * expose logger
   * @type {object}
   */
  this.logger = options.logger || bole(options.name || 'fbbot');

  /**
   * middleware storage (per event)
   * @type {object}
   * @private
   */
  this._stack = {};

  /**
   * lock-in public methods
   * wrap `_handler` with agnostic to accommodate different http servers
   * @type {function}
   */
  this.requestHandler = agnostic(this._handler.bind(this));

  // attach lifecycle filters
  inMiddleware(this);
  outMiddleware(this);

  /**
   * create incoming traverse paths
   * @type {Traverse}
   * @private
   */
  this._incoming = new Traverse(inTraverse.steps, {
    entry     : middleware.entryPoint,
    middleware: inTraverse.middleware.bind(this),
    emitter   : inTraverse.emitter.bind(this),
    prefix    : inTraverse.prefix
  });
  // wrap linkParent method
  this._incoming.linkParent = inTraverse.linkParent.bind(null, this._incoming.linkParent);

  /**
   * create outgoing traverse paths
   * @type {Traverse}
   * @private
   */
  this._outgoing = new Traverse(outTraverse.steps, {
    middleware: outTraverse.middleware.bind(this),
    emitter   : outTraverse.emitter.bind(this),
    prefix    : outTraverse.prefix
  });
  // wrap linkParent method
  this._outgoing.linkParent = outTraverse.linkParent.bind(null, this._outgoing.linkParent);
}
function Fbbot ( options ) { if ( ! ( this instanceof Fbbot ) ) return new Fbbot ( options ) ; /**
   * Custom options per instance
   * @type {object}
   */ this . options = merge ( Fbbot . defaults , options || { } ) ; /**
   * Store credentials
   * @type {object}
   */ this . credentials = { // keep simple naming for internal reference token : this . options . pageAccessToken || this . options . token , secret : this . options . verifyToken || this . options . secret } ; if ( ! this . credentials . token || ! this . credentials . secret ) { throw new Error ( 'Both `token` (pageAccessToken) and `secret` (verifyToken) are required' ) ; } // compose apiUrl this . options . apiUrl += this . credentials . token ; /**
   * expose logger
   * @type {object}
   */ this . logger = options . logger || bole ( options . name || 'fbbot' ) ; /**
   * middleware storage (per event)
   * @type {object}
   * @private
   */ this . _stack = { } ; /**
   * lock-in public methods
   * wrap `_handler` with agnostic to accommodate different http servers
   * @type {function}
   */ this . requestHandler = agnostic ( this . _handler . bind ( this ) ) ; // attach lifecycle filters inMiddleware ( this ) ; outMiddleware ( this ) ; /**
   * create incoming traverse paths
   * @type {Traverse}
   * @private
   */ this . _incoming = new Traverse ( inTraverse . steps , { entry : middleware . entryPoint , middleware : inTraverse . middleware . bind ( this ) , emitter : inTraverse . emitter . bind ( this ) , prefix : inTraverse . prefix } ) ; // wrap linkParent method this . _incoming . linkParent = inTraverse . linkParent . bind ( null , this . _incoming . linkParent ) ; /**
   * create outgoing traverse paths
   * @type {Traverse}
   * @private
   */ this . _outgoing = new Traverse ( outTraverse . steps , { middleware : outTraverse . middleware . bind ( this ) , emitter : outTraverse . emitter . bind ( this ) , prefix : outTraverse . prefix } ) ; // wrap linkParent method this . _outgoing . linkParent = outTraverse . linkParent . bind ( null , this . _outgoing . linkParent ) ; }
Fbbot instance constructor

@this Fbbot#
@param {object} options - list of customization parameters
@constructor
Fbbot instance constructor