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.1.2 to 0.1.3

53

lib/httpUtils.js

@@ -10,34 +10,39 @@ var axios = require('axios');

this.requestQueue = new Queue({ concurrency : options.maxConcurrent || 10000});
this.username = options.username;
this.password = options.password;
this.baseUrl = options.baseUrl;
this.headers = options.headers || {
this.http = axios.create({
baseURL: options.baseUrl,
timeout: options.requestTimeout || 30000,
auth : options.username && options.password && { username : options.username, password : options.password },
headers: options.headers || {
"Accept": "application/json",
"Content-Type": "application/json"
};
}
});
}
async get(uri, params, body, priority) {
return this._callRequest("get", uri, params, body, priority);
async get(url, opts, priority) {
return this._callRequest("get", url, opts, priority);
}
async put(uri, params, body, priority) {
return this._callRequest("put", uri, params, body, priority);
async put(url, opts, priority) {
return this._callRequest("put", url, opts, priority);
}
async post(uri, params, body, priority) {
return this._callRequest("post", uri, params, body, priority);
async post(url, opts, priority) {
return this._callRequest("post", url, opts, priority);
}
async downloadUrlAttachment(uri, priority) {
var res = await this.get(uri, {responseType : 'arraybuffer'}, null, priority);
var res = await this.get(uri, {responseType : 'arraybuffer'}, priority);
return res && res.data && (new Uint8Array(res.data));
}
async _callRequest(method, uri, params, body, priority){
async _callRequest(method, url, opts = {}, priority){
return new Promise((resolve, reject)=>{
let func = axios[method];
var doRequest = async ()=>{
let options = Object.assign(opts,{
url,
method
});
var doRequest = async ()=>{
return func(`${this.baseUrl}${uri}`, this._getRequestOpts(params, body));
return this.http.request(options);
}

@@ -62,18 +67,2 @@

}
_getRequestOpts(opts, body){
let options = Object.assign({
headers : this.headers,
data : body
}, opts);
if (this.username && this.password){
options.auth = {
username: this.username,
password: this.password
}
}
return options;
}
};
{
"name": "@capriza/http-utils",
"version": "0.1.2",
"version": "0.1.3",
"description": "HTTP Request utils that handles, request-response, errors, concurrency, priority and authentication",

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

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