Skip to content

Commit

Permalink
Merge pull request #39 from cesine/update_deps
Browse files Browse the repository at this point in the history
Update deps
  • Loading branch information
cesine authored Sep 12, 2019
2 parents 3ceda76 + 48237ad commit e2d6739
Show file tree
Hide file tree
Showing 8 changed files with 1,537 additions and 2,487 deletions.
36 changes: 36 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
// Enforcing
"bitwise": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noempty": true,
"noarg": true,
"nonew": true,
"plusplus": true,
"undef": true,
"unused": true,
"trailing": true,

// Relaxing
"expr": true,

"maxparams": 4,
"maxdepth": 4,
"maxstatements": 45, // Made this up
"maxcomplexity": 15, // Pulled from Steve McConnell
"maxlen": 160, // Two times 80 characters

// Node
"globals": {

"exports": true,
"require": true,
"process": true,
"module": true,
"setTimeout": true,
"Buffer": true
}
}
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ node_js:
- "12"
- "10"
- "8"

script
- npm run lint
- npm test
57 changes: 0 additions & 57 deletions Gruntfile.js

This file was deleted.

51 changes: 28 additions & 23 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ var log4js = require('log4js');
var und = require('lodash');
var util = require('util');

/*
* Parses authentication strings into objects or just passes back objects
*/
function parseAuth(auth) {
if (auth && typeof auth === 'string') {
var authObject = {
username: auth.split(':')[0],
password: auth.split(':')[1]
};
return authObject;
} else {
return auth;
}
}

/*
* Returns an HTTP status code error
*/
function getStatusCodeError(code) {
return new Error(http.STATUS_CODES[code] || 'Unknown HTTP Status Code');
}

/*
* Default content serializer for HTTP requests and responses
*/
Expand Down Expand Up @@ -84,6 +106,7 @@ util.inherits(Client, events.EventEmitter);
var instanceMethod = method.toLowerCase();

Client.prototype[instanceMethod] = function(args) {
/*jshint maxcomplexity:16 */

var originalArgs = und.clone(args);
args.headers = args.headers || {};
Expand Down Expand Up @@ -160,7 +183,11 @@ util.inherits(Client, events.EventEmitter);
var requestMethod = instanceMethod.toUpperCase();
var data = body;
var statusCode = response && response.statusCode || err && err.code || 'unknown';
this.emit('response', und.extend({statusCode: statusCode, duration: requestDuration, method: requestMethod}, und.pick(originalArgs, ['url', 'params'])));
this.emit('response', und.extend({
statusCode: statusCode,
duration: requestDuration,
method: requestMethod
}, und.pick(originalArgs, ['url', 'params'])));

// attempt deserialization

Expand Down Expand Up @@ -218,28 +245,6 @@ util.inherits(Client, events.EventEmitter);

});

/*
* Parses authentication strings into objects or just passes back objects
*/
function parseAuth(auth) {
if (auth && typeof auth === 'string') {
var authObject = {
username: auth.split(':')[0],
password: auth.split(':')[1]
};
return authObject;
} else {
return auth;
}
}

/*
* Returns an HTTP status code error
*/
function getStatusCodeError(code) {
return new Error(http.STATUS_CODES[code] || 'Unknown HTTP Status Code');
}

/*
* Creates a single instance of the client from a configuration object
*/
Expand Down
Loading

0 comments on commit e2d6739

Please sign in to comment.