@hocuspocus/extension-throttle 4.0.0-rc.6 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,11 +4,45 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@hocuspocus/extension-throttle)
|
|
5
5
|
[](https://github.com/sponsors/ueberdosis)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
Rate-limit and throttle connections to a [Hocuspocus](https://github.com/ueberdosis/hocuspocus) server by IP. Helps protect your collaboration backend from abuse, accidental reconnect loops, and misbehaving clients.
|
|
7
|
+
Rate-limit and throttle connections to a [Hocuspocus](https://github.com/ueberdosis/hocuspocus) server by IP. Protects your collaboration backend from abuse, accidental reconnect loops, and misbehaving clients.
|
|
9
8
|
|
|
10
|
-
##
|
|
11
|
-
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @hocuspocus/extension-throttle
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
With default thresholds (15 connection attempts per 60 seconds, 5 minute ban):
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { Server } from "@hocuspocus/server"
|
|
21
|
+
import { Throttle } from "@hocuspocus/extension-throttle"
|
|
22
|
+
|
|
23
|
+
const server = new Server({
|
|
24
|
+
extensions: [new Throttle()],
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
server.listen()
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Tune the limits
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
new Throttle({
|
|
34
|
+
throttle: 30, // allowed connection attempts per window
|
|
35
|
+
consideredSeconds: 60, // window length in seconds
|
|
36
|
+
banTime: 5, // ban duration in minutes
|
|
37
|
+
})
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Pass `throttle: false` (or `null`) to effectively disable the limiter without removing the extension.
|
|
41
|
+
|
|
42
|
+
## Documentation
|
|
43
|
+
|
|
44
|
+
Full options reference: [tiptap.dev/docs/hocuspocus/server/extensions/throttle](https://tiptap.dev/docs/hocuspocus/server/extensions/throttle).
|
|
12
45
|
|
|
13
46
|
## License
|
|
14
|
-
|
|
47
|
+
|
|
48
|
+
MIT — see [LICENSE.md](https://github.com/ueberdosis/hocuspocus/blob/main/LICENSE.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/extension-throttle",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "hocuspocus throttle extension",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@hocuspocus/server": "^4.0.0
|
|
31
|
+
"@hocuspocus/server": "^4.0.0"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "1c1b34800f702a06e1ce236e8a175c82876bff42",
|
|
34
34
|
"repository": {
|
|
35
35
|
"url": "https://github.com/ueberdosis/hocuspocus"
|
|
36
36
|
},
|