Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@capriza/http-utils

Package Overview
Dependencies
Maintainers
4
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capriza/http-utils - npm Package Compare versions

Comparing version 0.2.15 to 0.2.16-dev.0

alignVersions.js

21

lib/httpUtils.js
var axios = require('axios');
var BaseUtils = require("./baseUtils");
var Queue = require("./rateLimitQueue");

@@ -11,5 +10,4 @@ const CancelToken = axios.CancelToken;

module.exports = class HttpUtils extends BaseUtils {
module.exports = class HttpUtils {
constructor(options = {}){
super(options);
this.baseURL = options.baseURL || options.baseUrl;

@@ -24,2 +22,4 @@ this.retryInterval = (!isNaN(options.retryInterval) && options.retryInterval) || 5000;

this.requestQueue = new Queue(options.limit, options.interval, options.maxConcurrent);
this.loggingLevel = options.loggingLevel || "debug";
this.logger = this._getValidLogger(options.logger);
this.http = axios.create(Object.assign(options.requestConfig || {}, {

@@ -63,3 +63,3 @@ baseURL: this.baseURL,

retriesCount = retriesCount === undefined ? this.maxRetries : retriesCount;
const requestLog = logger || this.logger;
const requestLog = this._getValidLogger(logger);
return new Promise((resolve, reject) => {

@@ -89,3 +89,3 @@ try {

var timeout = setTimeout(() => {
requestLog.info("request time exceeded");
requestLog[this.loggingLevel]("request time exceeded");
try {

@@ -132,5 +132,4 @@ source.cancel('request was canceled due to time out');

}
requestLog[this.loggingLevel](`[HttpUtils] PRIORITY[${priority ? priority : 0}] HTTP ${method} request: ${cleanURL}`);
requestLog.debug(`[HttpUtils] PRIORITY[${priority ? priority : 0}] HTTP ${method} request: ${cleanURL}`);
this.requestQueue.add(doRequest, {priority}).then((response) => {

@@ -167,2 +166,10 @@ if(responseTypes.includes(responseType)) {

}
_getValidLogger(logger) {
if(!logger || typeof logger[this.loggingLevel] !== "function" || typeof logger.error !== "function") {
return this.logger || console;
}
return logger;
}
};
{
"name": "@capriza/http-utils",
"version": "0.2.15",
"version": "0.2.16-dev.0",
"description": "HTTP Request utils that handles, request-response, errors, concurrency, priority and authentication",
"main": "index.js",
"scripts": {
"test": "./node_modules/.bin/mocha --timeout 10000 --exit --reporter spec"
"test": "./node_modules/.bin/mocha --timeout 10000 --exit --reporter spec",
"test-coverageAndReport": "npm run test",
"build": "node scripts/build.js"
},

@@ -9,0 +11,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc