1.1.1 • Published 7 years ago

js-cfclient v1.1.1

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
7 years ago

JS CFClient

NPM that can be used to access the CloudFoundry API.

Getting started

Install the npm in your project npm install --save js-cfclient

Add require statement

const CF = require('js-cfclient');

Initialize the client with the following information:

  • protocol => http or https
  • host => FQDN or IP address of the PCF or CF host (e.g. api.mydomain.com)
  • username => Username to access the api
  • password => Password for the given username
  • skipSslValidation => Set to true when using self-signed certs
const CfClient = new CF.CFClient(new CF.CFConfig({
    protocol: 'https',
    host: 'api.myhost.com',
    username: 'admin',
    password: 'admin',
    skipSslValidation: true
}));

The CFClient uses Promises to manage callbacks.

Once you have configured the CFClient you can connect() and then respond accordingly.

CfClient.connect().then(() => {
    CfClient.request('organizations').then((resp) => {
        console.log('Response: ' + JSON.stringify(resp));
    }, console.error);
    CfClient.request('apps').then((resp) => {
        console.log('Response: ' + JSON.stringify(resp));
    }, console.error);
}, console.error);

Example project

You can find an example project here

Issues

Please use the Issues tab to report any problems or feature requests.