![38% of CISOs Fear They’re Not Moving Fast Enough on AI](https://cdn.sanity.io/images/cgdhsj6q/production/faa0bc28df98f791e11263f8239b34207f84b86f-1024x1024.webp?w=400&fit=max&auto=format)
Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@springworks/api-client
Advanced tools
Module for sending requests to other APIs through a circuit breaker
@springworks/api-client
Module for sending requests to other APIs through a circuit breaker created by @springworks/circuit-breaker-factory.
yarn add @springworks/api-client
createClient(params)
Creates a api client using the provided config. Returns an object that exposes a sendRequest(opts, expected_status_codes)
function that returns a Promise.
params
Name | Type | Description | Required |
---|---|---|---|
base_url | String | Fully qualified uri string used as the base url | Yes |
circuit_breaker_config | Object | Optional. The circuit breaker config. Please refer to this documentation for details. | Yes |
logger | Logger | See @springworks/logger-interfaces | Yes |
auth | Object | An object with username and password . | No |
opt_options | Object | No | |
opt_options.opt_auth | Object | Optional authentication object that will be used for all requests sent towards the provided base_url . If there is an auth property in the options send in sendRequest then opt_auth gets overwritten. | No |
opt_options.opt_timeout | Number | Timeout (millis) used in all request from created client. | No |
sendRequest(options, expected_status_codes)
Sends the request based on the provided options and returns a resolved/rejected Promise.
Options
Parameter | Description | Type | Required |
---|---|---|---|
endpoint_uri | URI of the endpoint that's to be reached | string | Yes |
expected_status_codes
Type | Description | Entries Type | Entries Range | Required |
---|---|---|---|---|
Array | Expected status codes by the invoker of this function | Number | [100, 500) | Yes |
Example Usage
var api_client_factory = require('@springworks/api-client');
var config = {
source_name: 'my-api',
target_name: 'facebook-graph-api',
window_duration: 1000, // optional
num_buckets: 10, // optional
timeout_duration: 3000, // optional
error_threshold: 50, // optional
volume_threshold: 5, // optional
};
var api_client = api_client_factory.createClient({
base_url: 'http://api.machinetohuman.com',
circuit_breaker_config: config,
logger: logger,
});
var options = {
endpoint_uri: '/vehicles/1234',
// other request options
};
var expected_status_codes = [200];
api_client
.sendRequest(options, expected_status_codes)
.then(function (response_body) {
// do your thing;
})
.catch(function (err) {
// err.code is the statusCode of the response or 417 (if responded with code < 400)
});
FAQs
Module for sending requests to other APIs through a circuit breaker
The npm package @springworks/api-client receives a total of 0 weekly downloads. As such, @springworks/api-client popularity was classified as not popular.
We found that @springworks/api-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.