New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@springworks/api-client

Package Overview
Dependencies
Maintainers
1
Versions
567
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@springworks/api-client

Module for sending requests to other APIs

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

API Client

Module for sending requests to other APIs through a circuit breaker created by @springworks/circuit-breaker-factory.

API

createClient(base_url, circuit_breaker_config, logger, opt_auth)

Creates a api client using the provided config. Returns an object that exposes a sendRequest(opts, callback) function.

base_url

Fully qualified uri string used as the base url

Config

The circuit breaker config. Please refer to this documentation for details.

Logger

Bunyan logger

opt_auth

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.

sendRequest(options, expected_status_codes, callback)

Options

ParameterDescriptionTypeRequired
endpoint_uriURI of the endpoint that's to be reachedstringYes

The rest of the options match the options from the request HTTP client module and can be seen there.

expected_status_codes

TypeDescriptionEntries TypeEntries RangeRequired
ArrayExpected status codes by the invoker of this functionNumber[100, 500)Yes

Example Usage

var api_client_factory = require('api-client');
var config = {
  source_name: 'my-api',
  target_name: 'facebook-graph-api',
  window_duration: 1000,
  num_buckets: 10,
  timeout_duration: 3000,
  error_threshold: 50,
  volume_threshold: 5
};

var api_client = api_client_factory.create('http://api.machinetohuman.com', config, bunyan_logger);

var options = {
  endpoint: '/vehicles/1234'
};

api_client.sendRequest(options, [200, 404] function(err, res, body) {
  // do your thing;
});

Keywords

FAQs

Package last updated on 25 Aug 2015

Did you know?

Socket

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.

Install

Related posts

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