You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Throw an error when the user reached their limit.
147
+
if (isBlocked) {
148
+
awaitthis.throwThrottlingException(context, {
149
+
limit,
150
+
ttl,
151
+
key,
152
+
tracker,
153
+
totalHits,
154
+
timeToExpire,
155
+
isBlocked,
156
+
timeToBlockExpire,
157
+
});
143
158
}
144
159
145
160
returntrue;
@@ -188,6 +203,10 @@ The following options are valid for the object passed to the array of the `Throt
188
203
<td><code>limit</code></td>
189
204
<td>the maximum number of requests within the TTL limit</td>
190
205
</tr>
206
+
<tr>
207
+
<td><code>blockDuration</code></td>
208
+
<td>the number of milliseconds that request will be blocked for that time</td>
209
+
</tr>
191
210
<tr>
192
211
<td><code>ignoreUserAgents</code></td>
193
212
<td>an array of regular expressions of user-agents to ignore when it comes to throttling requests</td>
@@ -217,6 +236,18 @@ If you need to set up storage instead, or want to use some of the above options
217
236
<td><code>throttlers</code></td>
218
237
<td>an array of throttler sets, defined using the table above</td>
219
238
</tr>
239
+
<tr>
240
+
<td><code>errorMessage</code></td>
241
+
<td>a <code>string</code> OR a function that takes in the <code>ExecutionContext</code> and the <code>ThrottlerLimitDetail</code> and returns a <code>string</code> which overrides the default throttler error message</td>
242
+
</tr>
243
+
<tr>
244
+
<td><code>getTracker</code></td>
245
+
<td>a function that takes in the <code>Request</code> and returns a <code>string</code> to override the default logic of the <code>getTracker</code> method</td>
246
+
</tr>
247
+
<tr>
248
+
<td><code>generateKey</code></td>
249
+
<td>a function that takes in the <code>ExecutionContext</code>, the tacker <code>string</code> and the throttler name as a <code>string</code> and returns a <code>string</code> to override the final key which will be used to store the rate limit value. This overrides the default logic of the <code>generateKey</code> method</td>
0 commit comments