0.0.6 β€’ Published 10 months ago

@runespoorstack/feature-toggles-imperative v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Table of Contents

Context

This package implement something that is called Release Feature Toggles. It is the simplest way to manage feature toggles - as code.

✨ Features

  • Convenient way to define feature toggles in code.
  • Validate feature toggles configuration.
  • Feature toggles history (via VSC).
  • Zero dependencies.

🦾 Installation

npm i @runespoorstack/feature-toggles-imperative

♾️ Usage

List app environments:

const ENVS = ['dev', 'qa', 'prod'] as const;

Use env variable name to get the current environment (vite example). You can use NODE_ENV or set your own variable:

const ENVS = ['dev', 'qa', 'prod'] as const;

const ENV_NAME = import.meta.env.VITE_ENV_NAME;

Define feature toggles configuration:

const FEATURE_TOGGLES = {
  feature1: {
    meta: {
      description: 'Feature 1',
      createdAt: '2023-01-01',
      createdBy: 'John Doe'
    },
    enabled: {
      dev: true,
      qa: false,
      prod: false
    },
  },
  feature2: {
    meta: {
      description: 'Feature 2',
      createdAt: '2023-01-02',
      createdBy: 'Jane Doe'
    },
    enabled: {
      dev: false,
      qa: false,
      prod: true
    },
    value: {
      dev: 'value4',
      qa: 'value5',
      prod: 'value6'
    }
  }
} as const;

Create feature toggles:

import { createFeatureToggles } from '@runespoorstack/feature-toggles-imperative';

const { getFeatureToggle } = createFeatureToggles({
  featureToggles: FEATURE_TOGGLES,
  envs: ENVS,
  env: ENV_NAME
});

Use feature toggles:

const feature1 = getFeatureToggle('feature2');
console.log(feature1);
// {
//   meta: {
//     description: 'Feature 1',
//     createdAt: '2023-01-01',
//     createdBy: 'John Doe'
//   },
//   enabled: true,
//   value: 'value6'
// }

πŸ› οΈ Contributing

See the CONTRIBUTING.md document.

πŸ’• Special Thanks

  • I want to say thank you to the best woman in the world, my wife Diana for her love, daily support, motivation and inspiration.

❀️ Support or Donate

If you are enjoying this work and feel extra appreciative, you could buy me a book πŸ“– or 3 πŸ“–πŸ“–πŸ“–.

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago

0.0.0

10 months ago