# vcap_services

> Parse and return service credentials from VCAP_SERVICES.

Latest version **0.7.1** (published 2019-07-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install vcap_services
pnpm add vcap_services
yarn add vcap_services
bun add vcap_services
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.1 |
| Published | 2019-07-19 |
| First published | 2015-09-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | German Attanasio Ruiz |
| Maintainers | germanattanasio |
| Keywords | bluemix, vcap_services, cloud-foundry |

## Links

- npm: https://www.npmjs.com/package/vcap_services
- Repository: https://github.com/germanattanasio/vcap_services
- Homepage: https://github.com/germanattanasio/vcap_services#readme
- Issues: https://github.com/germanattanasio/vcap_services/issues
- npm.io page: https://npm.io/package/vcap_services

## Recent versions

- 0.7.1 (latest) — 2019-07-19
- 0.7.0 — 2019-04-23
- 0.6.0 — 2018-10-12
- 0.5.1 — 2018-08-20
- 0.5.0 — 2018-08-03
- 0.4.0 — 2018-07-03
- 0.3.4 — 2017-04-13
- 0.3.2 — 2017-03-29
- 0.2.0 — 2016-05-20
- 0.1.7 — 2015-10-04
- 0.1.6 — 2015-10-01
- 0.1.5 — 2015-10-01
- 0.1.4 — 2015-09-30
- 0.1.3 — 2015-09-30
- 0.1.2 — 2015-09-30
- … 1 more at https://npm.io/package/vcap_services/versions

## README

# VCAP_SERVICES

[![Build Status](https://travis-ci.org/germanattanasio/vcap-services.svg?branch=master)](http://travis-ci.org/germanattanasio/vcap-services)
[![Coverage Status](https://coveralls.io/repos/germanattanasio/vcap-services/badge.svg?branch=master&service=github)](https://coveralls.io/github/germanattanasio/vcap-services?branch=master)
[![npm-version](https://img.shields.io/npm/v/vcap_services.svg)](https://www.npmjs.com/package/vcap_services)
[![npm-downloads](https://img.shields.io/npm/dm/vcap_services.svg)](https://www.npmjs.com/package/vcap_services)

Parse and return service credentials from `VCAP_SERVICES` environment variable that [Bluemix] provides.

## Installation

```sh
$ npm install vcap_services --save
```

## Usage

```javascript
var vcapServices = require('vcap_services');
var credentials = vcapServices.findCredentials({ service: 'personality_insights' });
console.log(credentials);
```

If `VCAP_SERVICES` is:
```json
{
  "personality_insights": [{
      "credentials": {
        "password": "<password>",
        "url": "<url>",
        "username": "<username>"
      },
    "label": "personality_insights",
    "name": "personality-insights-service",
    "plan": "standard"
  }]
}
```

Output:
```json
{
  "password": "<password>",
  "url": "<url>",
  "username": "<username>"
}
```

### Getting credentials for a specific plan

Get credentials that match a specific service plan (only for `VCAP_SERVICES`).
```javascript
var vcapServices = require('vcap_services');
var credentials = vcapServices.findCredentials({ service: 'personality_insights', instance: { plan: 'standard' } });
console.log(credentials);
```

### Getting credentials for a specific instance
Get credentials that match a specific service instance (replace "YOUR NLC NAME" with the name of your service instance).
```javascript
var vcapServices = require('vcap_services');
var credentials = vcapServices.findCredentials({ service: 'natural_language_classifier', { instance: { name: 'YOUR NLC NAME' } });
console.log(credentials);
```

### Getting credentials for a specific plan and instance
Get credentials that match a specific service plan and instance (replace "YOUR NLC NAME" with the name of your service instance).
```javascript
var vcapServices = require('vcap_services');
var credentials = vcapServices.findCredentials({ service: 'natural_language_classifier', instance: { plan: 'standard', name: 'YOUR NLC NAME' } });
console.log(credentials);
```

### Getting credentials for a specific tag
Get credentials that match a specific service tag, regardless of the service type.
```javascript
var vcapServices = require('vcap_services');
var credentials = vcapServices.findCredentials({ instance: { tags: 'object-storage' } });
console.log(credentials);
```

## Tests
Running all the tests:
```sh
$ npm test
```

Running a specific test:
```sh
$ mocha -g '<test name>'
```


## License

MIT.

## Contributing
See [CONTRIBUTING](https://github.com/germanattanasio/vcap-services/blob/master/CONTRIBUTING.md).

[Bluemix]: http://bluemix.net/

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