15.0.1 • Published 11 days ago

@financial-times/n-flags-client v15.0.1

Weekly downloads
1,208
License
-
Repository
-
Last release
11 days ago

n-flags-client

Provides a mechanism for us to toggle features and services, inspired by Martin Fowler’s feature toggles. Flags can be overridden using an x-flags header or next-flags cookie. Also sends reports to Sentry of any expired flags still in use.

Usage

Client side

Flags are exposed via flags.html, which are consumed by n-ui.

Server side

Any apps using n-express with the withFlags option turned on will get flags added to res.locals.flags, via the middleware it consumes in this repo. By default it will request from FT.com’s set of platinum flag services, but can be overridden using the setUrls([arr]) method.

The default behaviour when NODE_ENV=production is set is to get overrides from the HTTP header that Fastly sets. For apps that are not routed via Fastly, you can set OVERRIDE_FLAGS_FROM_COOKIE=true to get overrides from a cookie.

API

init(options)

Initialises the flag client. Options:

  • timeout: A length of time (ms) to wait for response from the flag server default 3000
  • interval: An interval (ms) between attempts to fetch fresh flag data default 30000
  • retry: The number of times to retry if a fetch fails default 1
  • filter: a function, returning true or false, that is passed the raw data object fora flag and is used to decide whether or not it should be discarded from the flag set for the current app

Returns a promise that is resolved when flags have been successfully fetched at least once (or that resolves immediately if none of the above options are passed).

getArray()

Returns a simplified array of flags similar to that retrieved from the flags API, but lacking expiry date information.

get(name)

Returns the current state of a flag (or false if the flag doesn’t exist). If no name is provided, it returns a hash of all current flag objects, including information on expiry dates.

getModel(name)

Returns a flag model for the named flag.

15.0.1

11 days ago

15.0.0

3 months ago

14.1.0

4 months ago

13.1.1

10 months ago

14.0.0

9 months ago

14.0.1

8 months ago

13.1.0

11 months ago

13.0.0

1 year ago

12.0.6

1 year ago

12.0.5

1 year ago

12.0.3

1 year ago

12.0.4

1 year ago

12.0.1

1 year ago

12.0.2

1 year ago

12.0.0

2 years ago

11.1.0

2 years ago

11.0.0

2 years ago

10.1.0

3 years ago

10.0.0

4 years ago

9.4.3

4 years ago

9.4.2

4 years ago

9.4.1

4 years ago

9.4.0

5 years ago

9.3.0

5 years ago

9.2.0

5 years ago

9.1.5

6 years ago

9.1.5-beta.1

6 years ago

9.1.4

6 years ago

9.1.3

6 years ago

9.1.2

6 years ago

9.1.1

6 years ago

9.1.0

6 years ago

9.0.4

6 years ago

9.0.3

6 years ago

9.0.2

6 years ago

9.0.1

6 years ago

9.0.0

7 years ago