npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cloudfoundry-client

v0.10.2

Published

Cloudfoundry client

Downloads

8

Readme

Cloudfoundry NG/v2 client

Supports interaction with Cloudfoundry.

Install:

npm install cloudfoundry-client

Current endpoint support includes:

  • apps
  • services
  • service_plans
  • service_instances
  • organizations
  • spaces
  • domains
  • runtimes
  • frameworks
  • events

Interaction is accomplished via client.<endpoint>.<method>. (see examples below)

Usage

Creating client

Authentication can be done via either token or login. If, however, the token expires, the login info will be used to acquire a new token. Hence, long running processes should consider the use of email/password.

var Client = require('cloudfoundry-client');

var client = new Client({
    host:  'pivotal.io',
    protocol: 'https:',
    token: 'XYZ',        // optional if email/password is provided
    email: 'my email'    // optional if token is provided
    password: 'password' // optional if token is provided
});

Getting from collections

Paging is accomplished automatically. For example, a request for apps will return all apps, not just those returned on the first page.

For example, to get all apps:

client.apps.get(function (err, apps) {
    console.log('your apps are:', apps);
});

Get a single item

var guid = < app guid >;

client.apps.get(guid, function (err, app) {
    console.log(util.format('app by %s is %s', guid, app));
});

Getting nested attributes:

There are two ways to do this. The first is to get the object, then call the method corresponding to its nested collection:

client.apps.get(guid, function (err, app) {
    // handle err
    app.summary.get(function (err, summary) {
        console.log(util.format('summary for app %s is %s', guid, summary));
    });
});

The drawback is that this requires 2 round trips to the server: first to get the app, then to get the summary via the summary endpoint.

This can be bypassed by omitting the callback on the first get:

client.apps.get(guid).summary.get(function (err, summary) {
    console.log(util.format('summary for app %s is %s', guid, summary));
});

This simply executes the call to the summary endpoint using the app's guid. The result from the apps.get, however, has no app data: only methods allowing the user to get nested collections.

The nested attributes convert the CF endpoints to camel. For example, service_instances is accessed in the client via serviceInstances:

client.apps.get(guid).serviceInstances.get(function (err, serviceInstances) {
    console.log(util.format('summary for app %s is %s', guid, summary));
});

Get logs:

client.apps.get(guid).instances.get(0).logs.get(function (err, logs) { // check err .. console.log('logs for instance 0 are:', log); });

Roadmap

See issues.