# request-service-discovery

> An extension to request to facilitate making requests against discoverable services

Latest version **1.0.7** (published 2017-09-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install request-service-discovery
pnpm add request-service-discovery
yarn add request-service-discovery
bun add request-service-discovery
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2017-09-21 |
| First published | 2015-10-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Steven Robinson |
| Maintainers | robinsio, stevenr |

## Links

- npm: https://www.npmjs.com/package/request-service-discovery
- Repository: https://github.com/ph0bos/request-service-discovery
- Issues: https://github.com/ph0bos/request-service-discovery/issues
- npm.io page: https://npm.io/package/request-service-discovery

## Dependencies (8)

- [uuid](https://npm.io/package/uuid.md) ^3.0.0
- [retry](https://npm.io/package/retry.md) ^0.8.0
- [bunyan](https://npm.io/package/bunyan.md) ^1.5.1
- [request](https://npm.io/package/request.md) ^2.65.0
- [unirest](https://npm.io/package/unirest.md) ^0.5.1
- [zoologist](https://npm.io/package/zoologist.md) 0.5.9
- [check-types](https://npm.io/package/check-types.md) ^7.0.0
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) ^7.0.0

## Recent versions

- 1.0.7 (latest) — 2017-09-21
- 1.0.6 — 2017-02-24
- 1.0.5 — 2017-01-20
- 1.0.4 — 2017-01-17
- 1.0.3 — 2016-11-24
- 1.0.2 — 2016-08-25
- 1.0.1 — 2016-06-20
- 0.0.25 — 2016-06-13
- 0.0.24 — 2016-06-03
- 0.0.23 — 2016-04-12
- 0.0.22 — 2016-04-12
- 0.0.21 — 2016-04-11
- 0.0.20 — 2016-03-11
- 0.0.19 — 2016-03-08
- 0.0.18 — 2016-02-09
- … 18 more at https://npm.io/package/request-service-discovery/versions

## README

# Request Service Discovery

Utility module for making HTTP requests against discoverable services registered with ZooKeeper.

[![NPM](https://nodei.co/npm/request-service-discovery.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/request-service-discovery/)

## Basic Usage

The following is the most basic usage of the client;

```javascript
'use strict';

var RequestServiceDiscovery = require('request-service-discovery');

// Instantiate a client
var client = new RequestServiceDiscovery({
  connectionString: '127.0.0.1:2181',
  basePath: 'services',
  serviceName: 'my/service/v1',
  providerStrategy: 'RoundRobin',
  verbose: false,
  timeout: 1000,
  retries: 2,
  minTimeout: 5,
  maxTimeout: 50,
  correlationHeaderName: 'My-Correlation-ID',
  connectTimeout: 5000,
  sessionTimeout: 30000
});

var query = {
  "myParam": "myValue"  
};

var headers = {
  "Content-Type": "application/json"  
};

var body = {
 "prop1": "value1",
 "prop2": "value2"  
};

client.on('connected', function() {

  // Invoke a GET request against the service
  client.get('item/search', { query: query, headers: headers }, function(err, res) {
    callback(err, res.body);
  });

  // Invoke a PUT request against the service
  client.put('item', { query: query, headers: headers }, body, function(err, res) {
    callback(err, res.body);
  });

  // Invoke a POST request against the service
  client.post('item', { query: query, headers: headers }, body, function(err, res) {
    callback(err, res.body);
  });

  // Invoke a DELETE request against the service
  client.delete('item', { query: query, headers: headers }, body, function(err, res) {
    callback(err, res.body);
  });

  // Invoke a GET request against the service
  client.method('item/search', { method: 'GET', query: query, headers: headers }, body, (err, res) {
    callback(err, res.body);
  });

});

```

---
_Source: https://npm.io/package/request-service-discovery · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
