Socket
Socket
Sign inDemoInstall

hubkit

Package Overview
Dependencies
2
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.3 to 4.0.0

59

hubkit.js

@@ -268,5 +268,7 @@ if (typeof require !== 'undefined') {

resolve(cachedItem.value);
} else if (!(res.status >= 200 && res.status < 300 || options.boolean &&
res.status === 404 && res.data && res.data.message === 'Not Found') ||
res.data && !res.data.data && res.data.errors) {
} else if (
!(res.status >= 200 && res.status < 300 ||
options.boolean && res.status === 404 && res.data && res.data.message === 'Not Found'
) || res.data && res.data.errors
) {
if (cacheable) {

@@ -276,8 +278,18 @@ options.cache.del(cacheKey);

}
if (res.status === 404 && typeof options.ifNotFound !== 'undefined') {
var status = res.status;
if (res.data && res.data.errors && res.status === 200) {
if (res.data.errors.every(function(error) {
return error.type === 'RATE_LIMITED' || error.type === 'FORBIDDEN';
})) status = 403;
else if (res.data.errors.every(function(error) {
return error.type === 'NOT_FOUND';
})) status = 404;
else status = 400;
}
if (status === 404 && typeof options.ifNotFound !== 'undefined') {
resolve(options.ifNotFound);
} else if (res.status === 410 && typeof options.ifGone !== 'undefined') {
} else if (status === 410 && typeof options.ifGone !== 'undefined') {
resolve(options.ifGone);
} else {
var errors = '', rateLimited = false;
var errors = '';
if (res.data && res.data.errors) {

@@ -294,17 +306,21 @@ errors = [];

}
if (errorItem.type === 'RATE_LIMITED') rateLimited = true;
}
errors = errors.join('; ');
if (res.data.message) errors = ' (' + errors + ')';
if (res.data.message && errors) errors = ' (' + errors + ')';
}
var statusError = new Error(
formatError('GitHub', res.status, (res.data && res.data.message || '') + errors)
formatError('GitHub', status, (res.data && res.data.message || '') + errors)
);
statusError.status = res.status;
if (res.status === 200) statusError.status = rateLimited ? 403 : 400;
statusError.status = status;
if (res.data && res.data.errors) statusError.errors = res.data.errors;
if (res.data && res.data.data) statusError.data = res.data.data;
statusError.method = options.method;
if (options.body && options.body.query && /^\s*query/.test(options.body.query)) {
statusError.method = 'GET';
}
statusError.path = path;
statusError.response = res;
if (options.logTag) statusError.logTag = options.logTag;
statusError.fingerprint =
['Hubkit', options.method, options.pathPattern, '' + res.status];
['Hubkit', options.method, options.logTag || options.pathPattern, '' + status];
handleError(statusError, res);

@@ -332,4 +348,3 @@ }

if (isGraphqlUrl(path)) {
var data = res.data.data;
var root = data, rootKeys = [];
var root = res.data.data, rootKeys = [];
while (true) {

@@ -363,3 +378,3 @@ if (!root || Array.isArray(root) || typeof root === 'string' ||

if (!result) {
result = res.data;
result = res.data.data;
delete root.pageInfo;

@@ -375,14 +390,2 @@ } else {

}
if (data.errors && data.errors.length) {
outer: for (var j = 0; j < data.errors.length; j++) {
var nextError = data.errors[j];
if (result.errors && result.errors.length) {
for (var k = 0; k < result.errors.length; k++) {
if (result.errors[k].message === nextError.message) continue outer;
}
}
result.errors = result.errors || [];
result.errors.push(nextError);
}
}
}

@@ -413,3 +416,3 @@ if (endCursor) {

} else {
result = res.data;
result = res.data.data;
}

@@ -416,0 +419,0 @@ } else if (res.data && (

{
"name": "hubkit",
"version": "3.0.3",
"version": "4.0.0",
"description": "GitHub API library for JavaScript, promise-based, for both NodeJS and the browser",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc