@spoosh/plugin-throttle 0.1.10 → 0.1.11

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 CHANGED
@@ -16,7 +16,7 @@ npm install @spoosh/plugin-throttle
16
16
  import { Spoosh } from "@spoosh/core";
17
17
  import { throttlePlugin } from "@spoosh/plugin-throttle";
18
18
 
19
- const client = new Spoosh<ApiSchema, Error>("/api").use([
19
+ const spoosh = new Spoosh<ApiSchema, Error>("/api").use([
20
20
  // ...otherPlugins,
21
21
  throttlePlugin(),
22
22
  ]);
@@ -34,6 +34,6 @@ const { data } = useRead((api) => api("expensive").GET(), { throttle: 1000 });
34
34
 
35
35
  ## Notes
36
36
 
37
- - Register this plugin at the end of your plugin list, to make sure it block even force fetch requests.
37
+ - This plugin runs with priority 100, automatically executing last in the middleware chain to block all requests (including force fetches) that exceed the throttle limit
38
38
  - Unlike debounce (which delays), throttle immediately returns cached data for extra requests
39
39
  - Useful for rate-limiting expensive endpoints
package/dist/index.d.mts CHANGED
@@ -15,16 +15,19 @@ type ThrottleWriteResult = object;
15
15
  * Limits how frequently a query can be executed, returning cached data
16
16
  * if the throttle window hasn't elapsed.
17
17
  *
18
+ * This plugin runs with priority 100, meaning it executes last in the middleware chain
19
+ * to block all requests (including force fetches) that exceed the throttle limit.
20
+ *
18
21
  * @see {@link https://spoosh.dev/docs/react/plugins/throttle | Throttle Plugin Documentation}
19
22
  *
20
23
  * @example
21
24
  * ```ts
22
25
  * import { Spoosh } from "@spoosh/core";
23
26
  *
24
- * const client = new Spoosh<ApiSchema, Error>("/api")
27
+ * const spoosh = new Spoosh<ApiSchema, Error>("/api")
25
28
  * .use([
26
- * // ... other plugins
27
29
  * throttlePlugin(),
30
+ * // ... other plugins
28
31
  * ]);
29
32
  *
30
33
  * // Throttle to max once per second
package/dist/index.d.ts CHANGED
@@ -15,16 +15,19 @@ type ThrottleWriteResult = object;
15
15
  * Limits how frequently a query can be executed, returning cached data
16
16
  * if the throttle window hasn't elapsed.
17
17
  *
18
+ * This plugin runs with priority 100, meaning it executes last in the middleware chain
19
+ * to block all requests (including force fetches) that exceed the throttle limit.
20
+ *
18
21
  * @see {@link https://spoosh.dev/docs/react/plugins/throttle | Throttle Plugin Documentation}
19
22
  *
20
23
  * @example
21
24
  * ```ts
22
25
  * import { Spoosh } from "@spoosh/core";
23
26
  *
24
- * const client = new Spoosh<ApiSchema, Error>("/api")
27
+ * const spoosh = new Spoosh<ApiSchema, Error>("/api")
25
28
  * .use([
26
- * // ... other plugins
27
29
  * throttlePlugin(),
30
+ * // ... other plugins
28
31
  * ]);
29
32
  *
30
33
  * // Throttle to max once per second
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ function throttlePlugin() {
30
30
  return {
31
31
  name: "spoosh:throttle",
32
32
  operations: ["read", "infiniteRead"],
33
+ priority: 100,
33
34
  middleware: async (context, next) => {
34
35
  const pluginOptions = context.pluginOptions;
35
36
  const throttleMs = pluginOptions?.throttle;
package/dist/index.mjs CHANGED
@@ -4,6 +4,7 @@ function throttlePlugin() {
4
4
  return {
5
5
  name: "spoosh:throttle",
6
6
  operations: ["read", "infiniteRead"],
7
+ priority: 100,
7
8
  middleware: async (context, next) => {
8
9
  const pluginOptions = context.pluginOptions;
9
10
  const throttleMs = pluginOptions?.throttle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spoosh/plugin-throttle",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Request throttling plugin for Spoosh - limits request frequency",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,11 +33,11 @@
33
33
  }
34
34
  },
35
35
  "peerDependencies": {
36
- "@spoosh/core": ">=0.12.0"
36
+ "@spoosh/core": ">=0.12.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@spoosh/test-utils": "0.1.8",
40
- "@spoosh/core": "0.12.0"
39
+ "@spoosh/core": "0.12.1",
40
+ "@spoosh/test-utils": "0.1.8"
41
41
  },
42
42
  "scripts": {
43
43
  "dev": "tsup --watch",