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

izanami-node

v1.11.5

Published

Client for Izanami

Downloads

128

Readme

Node js client

Install

npm install izanami-node

Import

const Izanami = require('izanami-node');

Usage

The node client expose conveniant methods to call Izanami.

Configure the client:

const izanamicConfig = Object.assign({}, Izanami.defaultConfig, {
  host: 'http://localhost:9000',
  clientId: process.env.CLIENT_ID || 'xxxx',
  clientSecret: process.env.CLIENT_SECRET || 'xxxx',
});

// Get a configs client
const configClient = Izanami.configClient(izanamicConfig);
// Get a feature client 
const featureClient = Izanami.featureClient(izanamicConfig);
// Get a experiments client 
const experimentsClient = Izanami.experimentsClient(izanamicConfig);

Configs

Get a config

configClient.config("my.config.id").then(config => {
  console.log('The config is ', config);
  tree.should.be.deep.equal({
      "value": "test"
  })
});

Get the configs tree

configClient.configs("my.config.*").then(tree => {
  tree.should.be.deep.equal({
      "my": {
        "config": {
          "id": {
            "value": "test"
          },
          "id2": {
            "another": {
              "value": "a value"
            }
          }
        }
      }
    });
});

Features

Check a feature

featureClient.checkFeature("my.feature.id").then(active => {
  console.log('The feature is ', active);
});

Or with a context:

featureClient.checkFeature("my.feature.id", {client: "[email protected]"}).then(active => {
  console.log('The feature is ', active);
});

Get the features tree

featureClient.features("my.feature.*").then(tree => {
  tree.should.be.deep.equal({
    "my": {
      "feature": {
        "id": {
          "active": true
        },
        "id2": {
          "active": false
        }
      }
    }
  });
});

Or with a context:

featureClient.features("my.feature.*", {client: "[email protected]"}).then(tree => {
  tree.should.be.deep.equal({
    "my": {
      "feature": {
        "id": {
          "active": true
        },
        "id2": {
          "active": false
        }
      }
    }
  });
});

Experiments

Get an experiment

experimentsClient.experiment("my.experiment.id").then(experiment => {
  //Empty json if the experiment doesn't exists 
  console.log('The experiment is ', experiment);
});

Get experiments as tree

experimentsClient.experiments("my.experiment.*", "[email protected]").then(tree => {
  //Empty json if the experiment doesn't exists 
  console.log('The experiment is ', experiment);
  tree.should.be.deep.equal({
    "my": {
      "experiment": {
        "id": {
          "variant": "A"
        },
        "id2": {
          "variant": "B"
        }
      }
    }
  })
});

Get a variant

experimentsClient.variantFor("my.experiment.id", "[email protected]").then(variant => {
  //Empty json if the variant doesn't exists 
  console.log('The variant is ', variant);
});

Mark variant displayed

experimentsClient.displayed("my.experiment.id", "[email protected]").then(__ => {
  console.log('The variant is marked displayed');
});

Mark variant won

experimentsClient.won("my.experiment.id", "[email protected]").then(__ => {
  console.log('The variant is marked won');
});

Express proxy

You use express as a proxy to expose Izanami to the client side.

const app = express();

Izanami.expressProxy({
  sessionPath: '/api/izanami', // default '/api/me'
  featureClient, // Optional
  experimentsClient, // Optional
  configClient, // Optional
  app, // Express app 
  path: 'my.namespace.*' // The pattern to filter experiments, configs and features
});