Skip to content

AustinMatherne/pcf-services-parser

Repository files navigation

pcf-services-parser

npm node David Greenkeeper badge

Travis (.com) LGTM Alerts Code Climate maintainability Code Climate coverage Mutation testing badge

Returns PCF service credentials as an object of ENV formatted strings.

Given the service configuration:

{
  "VCAP_SERVICES": {
    "user-provided": [
      {
        "name": "db-service",
        "credentials": {
          "username": "db-username",
          "password": "db-password"
        }
      }
    ],
    "p-rabbitmq": [
      {
        "name": "message-broker",
        "credentials": {
          "username": "broker-username",
          "password": "broker-password"
        }
      }
    ]
  }
}
import { getPcfServiceCredentials } from "pcf-services-parser";

getPcfServiceCredentials();
// {
//   DB_SERVICE_USERNAME: "db-username",
//   DB_SERVICE_PASSWORD: "db-password",
//   MESSAGE_BROKER_USERNAME: "broker-username",
//   MESSAGE_BROKER_PASSWORD: "broker-password"
// };