npm

@lemonstand.org/lemonflags
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Lemonflags

DynamoDB-based feature flag library for Lemonstand.

Usage

In code

import { Lemonflags } from '@lemonstand.org/lemonflags'

const flags = new Lemonflags(DYNAMODB_ENDPOINT, AWS_REGION, TABLE_NAME);
// deprecated!
// const f = await flags.isFeatureEnabled("feature-name", 15, 22);
// prefer this!
const f = await flags.isFeatureEnabledForZoneId("feature-name", 300);

if (f) {
    // show feature
} else {
    // don't show feature
}

You might also need to declare permissions for your app in order to read the table:

# serverless.yml
provider:
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
      Resouce: ${lemonflagsARN}
# If using the new and preferred isFeatureEnabledForZoneId, also ask for
    - Effect: "Allow"
      Action:
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
      Resouce: ${lemonflagsARN}//index/feature-zone_id-index

As you can see, this library is read-only; we assume you have some other way of toggling the feature flags.

Setting flags

The schema declares only two fields: feature and game_instance_id. However, we expect a third field: enabled. The full schema is thus,

  • feature is the string label of the feature we want to flag.
  • DEPRECATED game_instance_id is a composite field of the game id and the instance id, delimited with a dash.
  • INTRODUCED v1.1.0 zone_id is the zone id for the environment we want the feature flag to apply. Will replace game_instance_id in a non-backwards-compatible release.
  • enabled is a boolean field.

Readme

Keywords

none

Package Sidebar

Install

npm i @lemonstand.org/lemonflags

Weekly Downloads

2

Version

1.1.0

License

UNLICENSED

Unpacked Size

7.61 MB

Total Files

1952

Last publish

Collaborators

  • sashamat
  • jonasbraga-ggs
  • abuhler_ggs
  • keep_it_simple
  • andreaspizsa
  • ggs-skunkbot
  • chadestioco