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

ksks

v1.1.1

Published

Ken Sheedlo's Keystone client

Downloads

15

Readme

ksks

A Keystone client implementation with caching.

Installation

$ npm install ksks

API

ksks([options])

Creates a Keystone client with the specified options. These may include

  • cache - A cache. It should be API compatible with node-cache-manager caches, meaning it should support the following functions:

    set(key, val, ttl, cb)
    get(key, cb)
    del(key, cb)

    where key is a string, val can be anything, ttl is an integer number of seconds and cb is a callback for the result.

  • identityEndpoint - The Keystone identity endpoint to use, as a string. Defaults to https://identity.api.rackspacecloud.com/v2.0/tokens.

client#authenticate(props, cb)

ksks.authenticate(props, cb)

Authenticates and returns an access response to the calback. props is a hash containing the following keys:

  • username - REQUIRED The username to log in as.
  • apiKey - The API key to use. If it is not supplied, a password must be used instead.
  • password - The password to use. If it is not supplied, an API key must be present.

The callback takes two arguments (err, res) where err is the error that occurred, if any, and res.access is the access from Keystone containing an access token and a service catalog.

When called as a client method, this function uses the configuration that the client was initialized with. When called as the function on ksks, it uses a default configuration and default in-memory cache.

ksks.endpoint(catalog, props)

Parses the existing catalog for a public endpoint satisfying the specified criteria. Criteria are specified in the props configuration object and may include:

  • service - The name of the service, e.g., 'cloudBlockStorage'. This argument is required.
  • region - The desired region as a 3-letter code, e.g., 'HKG'. If not specified and the requested service has more than one region, the region will be chosen arbitrarily.

ksks.token(catalog)

Parses the catalog and returns the auth token.

Example

ksks.authenticate({
  username: 'test',
  password: 'secretlol'
}, function (err, catalog) {
  var endpoint = ksks.endpoint(catalog, { service: 'cloudMonitoring' }),
    token = ksks.token(catalog);

  request({
    method: 'GET',
    uri: endpoint + '/entities',
    json: true,
    headers: {
      'x-auth-token': token,
      accept: 'application/json'
    }
  }, function (err, res, body) {
    // body contains your monitoring entities
    console.log(body);
  });
});