0.0.10 β€’ Published 1 year ago

@runespoorstack/feature-toggles-imperative v0.0.10

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago