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
Copy file name to clipboardExpand all lines: README.md
+36-10Lines changed: 36 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -249,11 +249,25 @@ const tap = mock.taps.inject(
249
249
250
250
# Rate Limiting
251
251
252
-
MockHttp supports rate limiting using [@fastify/rate-limit](https://github.com/fastify/fastify-rate-limit). Rate limiting is **disabled by default**and can be enabled by providing configuration options.
252
+
MockHttp supports rate limiting using [@fastify/rate-limit](https://github.com/fastify/fastify-rate-limit). Rate limiting is **enabled by default**at **1000 requests per minute** with **localhost (127.0.0.1 and ::1) excluded** from rate limiting.
253
253
254
-
## Enabling Rate Limiting
254
+
## Default Rate Limiting
255
255
256
-
To enable rate limiting, pass a `rateLimit` configuration object when creating your MockHttp instance:
256
+
By default, MockHttp applies the following rate limit:
257
+
-**1000 requests per minute** per IP address
258
+
-**Localhost is excluded** - requests from 127.0.0.1 and ::1 bypass rate limiting (ideal for local development and testing)
259
+
260
+
```javascript
261
+
import { MockHttp } from'@jaredwray/mockhttp';
262
+
263
+
constmock=newMockHttp();
264
+
awaitmock.start();
265
+
// Rate limiting is active (1000 req/min) except for localhost
266
+
```
267
+
268
+
## Customizing Rate Limiting
269
+
270
+
To customize rate limiting, pass a `rateLimit` configuration object when creating your MockHttp instance:
257
271
258
272
```javascript
259
273
import { MockHttp } from'@jaredwray/mockhttp';
@@ -351,15 +365,27 @@ const mock = new MockHttp({
351
365
352
366
## Disabling Rate Limiting
353
367
354
-
Rate limiting is disabled by default. To explicitly disable it (or disable it after it was enabled):
368
+
To disable rate limiting completely, set the `rateLimit` option to `false`:
355
369
356
370
```javascript
357
-
constmock=newMockHttp(); // No rateLimit option = disabled
0 commit comments