From ff5554ab68a963bd3bc738f544ee71cea79d7df3 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Sun, 7 Mar 2021 09:29:56 -0800 Subject: [PATCH] Added comments --- src/middleware/route-ratelimit.js | 14 ++++++++++++++ test/v4/rate-limits.js | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/src/middleware/route-ratelimit.js b/src/middleware/route-ratelimit.js index 8b2310a..722a970 100644 --- a/src/middleware/route-ratelimit.js +++ b/src/middleware/route-ratelimit.js @@ -8,6 +8,20 @@ The rate limits below were originially coded with the idea of charging on a per-resource basis. However, that was confusing to end users trying to purchase a subscription. So everything was simplied to two tiers: paid and anonymous + + CT 3/7/21 + This rate limits have been refactored to consider the following use cases: + - Users who want to buy a JWT token for 24 hour access. + - Users who want to buy different RPM tiers: 100, 250, 600 + - Basic Authentication which should not have any rate limits applied. + - Users that run bch-api locally and do not want any rate limits applied. + + The second two use cases also apply to internal rate limits. The internal rate + limits should not be applied to calls from those users. + + A lot of attention has been paid to passing rate-limit information for the user + when they trigger an endpoint that makes a lot of internal API calls. Examples + are hydrateUtxos() and getPublicKey(). */ 'use strict' diff --git a/test/v4/rate-limits.js b/test/v4/rate-limits.js index b88809b..c79068e 100644 --- a/test/v4/rate-limits.js +++ b/test/v4/rate-limits.js @@ -1,3 +1,7 @@ +/* + Unit tests for the rate limit middleware. +*/ + 'use strict' const chai = require('chai')