Skip to content

Commit

Permalink
docs: side-effect of generator
Browse files Browse the repository at this point in the history
  • Loading branch information
rayriffy committed Nov 24, 2023
1 parent 0e63b7e commit 68a1178
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ Message to be sent when rate limit was reached

Custom key generator to categorize client requests, return as a string. By default, this plugin will categorize client by their IP address via [`server.requestIP()` function](https://github.com/oven-sh/bun/pull/6165).

If you deploy your server behind a proxy (i.e. NGINX, Cloudflare), you may need to implement your own generator to get client's real IP address.

```js
const cloudflareGenerator = (req, server) =>
// get client ip via cloudflare header first
req.headers.get('CF-Connecting-IP')
// if not found, fallback to default generator
?? server?.requestIP(req)?.address
?? ''
```
### countFailedRequest
`boolean`
Expand Down

0 comments on commit 68a1178

Please sign in to comment.