Example Express app that shows how to use LaunchDarkly's node SDK as a rate limit provider for express-rate-limit.
This shows how LaunchDarkly operational feature flags can be used for service protection. Here - we allow detailed targeting at the user or customer account level.
In order to make this example production-ready, the following changes must be made:
- Rate limiting should be unique per endpoint, or class of endpoints
- Replace the in-memory store with a redis store
- Consider rate limiting un-authenticated requests as well
- Create a single feature flag called
rate-limiting
- Create the following rules
Name | Count |
---|---|
Suspended | 1 |
Low | 3 |
High | 10 |
Unlimited | -1 |
- Add user targeting so
alice
is served theSuspended
variation - Add user targeting so
max
is served theUnlimited
variation - Add rule targeting so
customerAccountId=2
is served theHigh
variation