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

sekando-cloud-client

v0.0.2-beta.0

Published

Node.js client for Sekando Cloud APIs

Downloads

1

Readme

Sekando Cloud APIs Node.js client

This is the official Node.js client library for Sekando Cloud Services APIs

Setup

Before getting started, you will need a Sekando Account and a project. You can sign up for free at https://sekando.com/register. Once you have an account and project, you can install the Node.js client from NPM: npm install sekando-cloud-client

Usage

For examples, see this repository

SekandoCloudClient

A SekandoCloudClient is initialized with your API key and project ID. Cluster Manager and other APIs will use this object's configuration to authenticate requests.

const SekandoCloudClient = require('sekando-cloud-client')
const client = new SekandoCloudClient({
  apiKey: SEKANDO_API_KEY, /* required */
  apiSecret: SEKANDO_API_SECRET, /* required */
  projectId: SEKANDO_PROJECT_ID, /* required */
  id: MACHINE_ID
})

apiKey, apiSecret, and projectId are required for making requests. id is used for making requests that are dependent on identifying each client. You should set this to a per-machine unique ID (such as /etc/machine-id found on most modern linux build) when using features such as Cluster Member update notifications.

ClusterManager

A ClusterManager can be created using a SekandoCloudClient instnace.

const client = new SekandoCloudClient({/*my config*/})
const clusterManager = client.clusterManager()

Functions

getClusterWith(id)

Returns a Cluster object with the given ID.

Example:

const cluster = testClusterManager.clusterWithId(myClusterId)
cluster.get()
  .then(_ => {
    // do something with cluster info
  })

Cluster

Functions

get()

Fetches cluster data. Returns promise. Resolves with modified and created dates. If the cluster does not exist, promise resolves with empty object

const cluster = testClusterManager.clusterWithId(myClusterId)
cluster.get()
  .then(_ => {
    console.log(new Date(cluster.created))
    console.log(new Date(cluster.modified))
  })
getMembers()

Fetches cluster members. Returns promise. Resolves with array of ClusterMember objects.

const cluster = testClusterManager.clusterWithId(myClusterId)
cluster.getMembers()
  .then(members => {
    members.forEach(member => {
      // do something
    })
  })
getMembers()

Fetches cluster members. Returns promise. Resolves with array of ClusterMember objects.

const cluster = testClusterManager.clusterWithId(myClusterId)
cluster.getMembers()
  .then(members => {
    members.forEach(member => {
      // do something
    })
  })
getMemberWithId(memberId)

Fetches member with given ID. Returns promise. Resolves with ClusterMember objects. If the member doesn't exist, prperties of member are unset.

const cluster = testClusterManager.clusterWithId(myClusterId)
cluster.getMemberWithId('test-member')
  .then(member => {
    // do something
  })

ClusterMember

A member of a cluster. Used to fetch/update member metadata. Emits change event when changes to the metadata are found using long polling to the API.

Properties

  • id ID of member. Unique within cluster.
  • modified Date last modified as milliseconds since epoch.
  • created Date last modified as milliseconds since epoch.
  • metadata The metadata uploaded to the Cluster Manager API.

Events

change

Emitted when updates are found. Automatically overwrites the metdata property

cluster.getMemberWithId('my-member')
  .then(member => {
    member.on('change', _ => {
      console.log('Member changed!', member.metadata)
    })
  })

Functions

setMetadata(metadata)

Updates cluster metadata. Returns promise.

cluster.getMemberWithId('my-member')
  .then(member => {
    member.setMetadata('all your base are belong to us')
  })