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

@cap-js-community/feature-toggle-library

v1.2.2

Published

SAP BTP feature toggle library enables Node.js applications using the SAP Cloud Application Programming Model to maintain live-updatable feature toggles via Redis.

Downloads

239

Readme

SAP BTP Feature Toggle Library

npm version monthly downloads REUSE status Main CI

SAP BTP feature toggle library enables Node.js applications using the SAP Cloud Application Programming Model to maintain live-updatable feature toggles via Redis.

Getting Started (CAP Feature Toggles)

  • Set up project with @sap/cds.

  • Install library:

    npm install --save @cap-js-community/feature-toggle-library
  • For CAP Feature Toggles everything is configured automatically.

  • The library acts as a CDS-Plugin and registers a FeatureService, which can be used to check and update toggles.

  • For details see Example CAP Server.

Getting Started (Custom Configuration)

  • Same as previous section.

  • Write toggles.yaml configuration file:

    # info: check api priority; 0 means access is disabled
    /check/priority:
      type: number
      fallbackValue: 0
      validations:
        - scopes: [user, tenant]
        - regex: '^\d+$'
  • Add configuration path to package.json:

    {
      "cds": {
        "featureToggles": {
          "configFile": "./toggles.yaml"
        }
      }
    }
  • Write usage code in handlers:

    const toggles = require("@cap-js-community/feature-toggle-library");
    
    const priorityHandler = async (context) => {
      const user = context.user.id;
      const tenant = context.tenant;
      const value = toggles.getFeatureValue("/check/priority", { user, tenant });
      if (value <= 0) {
        return context.reject("blocked");
      } else if (value < 10) {
        return context.reply("welcome");
      } else {
        return context.reply("very welcome");
      }
    };

Features

  • Maintain feature toggle states consistently across multiple app instances.
  • Feature toggle changes are published from Redis to subscribed app instances with publish/subscribe pattern PUB/SUB.
  • Horizontal app scaling is supported and new app instances will start with the correct state, or fallback values, if they cannot connect to Redis.
  • Feature toggle values can be changed specifically for accessors with certain scopes, e.g., for specific tenants, users,...
  • Users can register change handler callbacks for specific toggles.
  • Users can register custom input validation callbacks for specific toggles.
  • Works as a CDS-Plugin and provides a REST service to read and manipulate toggles.

Peers

Documentation

Head over to our Documentation to learn more.

Support, Feedback, Contributing

This project is open to feature requests/suggestions, bug reports etc. via GitHub issues. Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our Contribution Guidelines.

Code of Conduct

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its Code of Conduct at all times.

Licensing

Copyright 2023 SAP SE or an SAP affiliate company and feature-toggle-library contributors. Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.