@lemonstand.org/lemonflags
v1.1.0
Published
feature flag library for lemonstand
Downloads
2
Keywords
Readme
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 replacegame_instance_id
in a non-backwards-compatible release. enabled
is a boolean field.