Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@capriza/http-utils
Advanced tools
HTTP Request utils that handles, request-response, errors, concurrency, priority and authentication
Http requests client based on axios.
The Http-Utils library supports rate limits, concurrent requests, retry requests, request prioritization etc.
$ npm install @capriza/http-utils
An http-utils instance can be configured with the following properties:
default: { Accept: "application/json", Content-Type: "application/json" }
Maximum duration (milliseconds) allowed for request execution
default: 30000
Base URL for requests executed by this instance.
Request authentication by username and password, formatted as follows:
{ username : 'aaa', password : '123456' }
Maximum retries permitted in case of server or network errors, depending on settings of retryStatusCodes and retryNetworkErrors, respectively.
default: 0
Amount of time (milliseconds) between retries.
If one of these values is received as the error code of the response, a retry of the request will be triggered.
default: ["ECONNABORTED", "ECONNRESET"]
If one of these values is received as the status code of the response, a retry of the request will be triggered.
default: [502, 503, 504]
Maximum number of http requests per interval.
default: Infinity
Amount of time (milliseconds) during which the http requests limit can to be executed.
default: 1000
Number of requests allowed to execute simultaneously
default: Infinity
The available instance methods are listed below:
httpClient.get(url, data, props)
httpClient.post(url, data, props)
httpClient.put(url, data, props)
httpClient.patch(url, data, props)
httpClient.head(url, data, props)
Instance with base URL, 5 http requests allowed every 10 seconds, allowing 3 retries in case of network or server (502, 503) errors.
const HttpUtils = require('@capriza/http-utils');
const httpClient = new HttpUtils({
baseUrl: 'https://api.xxxxxxx.xx',
limit: 5,
interval: 10 * 1000,
maxRetries: 3,
retryStatusCodes: [502, 503]
});
Performing a GET
request with priority
const HttpUtils = require('@capriza/http-utils');
const httpClient = new HttpUtils( { baseUrl: 'https://api.xxxxxxx.xx' } );
try {
let result = await httpClient.get('/route', {}, { priority: true })
console.log(result);
} catch(ex) {
console.error(ex);
}
Performing a POST
request
const HttpUtils = require('@capriza/http-utils');
const headers = {
Content-Type: "application/x-www-form-urlencoded"
};
const httpClient = new HttpUtils( {
baseUrl: 'https://api.xxxxxxx.xx',
headers,
retryStatusCodes: [502, 503]
maxRetries: 3
});
try {
let result = await httpClient.post('/route', { data: 'sessionId=aaa-bbb-ccc&token=xxx-yyy-zzz' });
console.log(result);
} catch(ex) {
console.error(ex);
}
FAQs
HTTP Request utils that handles, request-response, errors, concurrency, priority and authentication
The npm package @capriza/http-utils receives a total of 0 weekly downloads. As such, @capriza/http-utils popularity was classified as not popular.
We found that @capriza/http-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.