Giter Site home page Giter Site logo

vcap-services's Introduction

VCAP_SERVICES

Build Status Coverage Status npm-version npm-downloads

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

Installation

$ npm install vcap_services --save

Usage

var vcapServices = require('vcap_services');
var credentials = vcapServices.getCredentials('personality_insights');
console.log(credentials);

If VCAP_SERVICES is:

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

Output:

{
  "password": "<password>",
  "url": "<url>",
  "username": "<username>"
}

Getting credentials for a specific plan

Get credentials that match a specific service plan (only for VCAP_SERVICES).

var vcapServices = require('vcap_services');
var credentials = vcapServices.getCredentials('personality_insights', '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).

var vcapServices = require('vcap_services');
var credentials = vcapServices.getCredentials('natural_language_classifier', null, '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).

var vcapServices = require('vcap_services');
var credentials = vcapServices.getCredentials('natural_language_classifier', 'standard', 'YOUR NLC NAME');
console.log(credentials);

Tests

Running all the tests:

$ npm test

Running a specific test:

$ mocha -g '<test name>'

License

MIT.

Contributing

See CONTRIBUTING.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.