Skip to content

Commit

Permalink
Always set a default empty {} value for client opts
Browse files Browse the repository at this point in the history
Fixes #154
  • Loading branch information
Leah Jones committed Mar 1, 2016
1 parent 094d128 commit 1cdb80f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions lib/clients/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var callTransport = require('./transports/call-transport');
* @constructor
*/
function BaseAPIClient(token, opts) {
var clientOpts = opts || {};
EventEmitter.call(this);

/**
Expand All @@ -41,18 +42,18 @@ function BaseAPIClient(token, opts) {
this._token = token;

/** @type {string} */
this.slackAPIUrl = opts.slackAPIUrl || 'https://slack.com/api/';
this.slackAPIUrl = clientOpts.slackAPIUrl || 'https://slack.com/api/';

/** @type {Function} */
this.transport = opts.transport || requestsTransport;
this.transport = clientOpts.transport || requestsTransport;

/** @type {string} */
this.userAgent = opts.userAgent || 'node-slack';
this.userAgent = clientOpts.userAgent || 'node-slack';

/**
* Default to attempting 5 retries within 5 minutes, with exponential backoff.
*/
this.retryConfig = opts.retryConfig || {
this.retryConfig = clientOpts.retryConfig || {
retries: 5,
factor: 3.9
};
Expand All @@ -64,14 +65,14 @@ function BaseAPIClient(token, opts) {
*/
this.requestQueue = async.priorityQueue(
bind(this._callTransport, this),
opts.maxRequestConcurrency || 3
clientOpts.maxRequestConcurrency || 3
);

/**
* The logger function attached to this client.
* @type {Function}
*/
this.logger = opts.logger || getLogger(opts.logLevel);
this.logger = clientOpts.logger || getLogger(clientOpts.logLevel);

this._createFacets();
}
Expand Down
3 changes: 2 additions & 1 deletion lib/clients/web/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ var facets = require('./facets/index');
* @constructor
*/
function WebAPIClient(token, opts) {
BaseAPIClient.call(this, token, opts);
var clientOpts = opts || {};
BaseAPIClient.call(this, token, clientOpts);
}

inherits(WebAPIClient, BaseAPIClient);
Expand Down

0 comments on commit 1cdb80f

Please sign in to comment.