@orpc/ratelimit 2.0.0-beta.23 → 2.0.0-beta.25

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
@@ -44,6 +44,7 @@ You can read the documentation [here](https://orpc.dev).
44
44
 
45
45
  - [@orpc/publisher](https://www.npmjs.com/package/@orpc/publisher): Pub/Sub with memory, Redis, and Upstash adapters.
46
46
  - [@orpc/ratelimit](https://www.npmjs.com/package/@orpc/ratelimit): Rate limiting with memory, Redis, and Upstash adapters.
47
+ - [@orpc/hibernation](https://www.npmjs.com/package/@orpc/hibernation): Leverage Hibernation APIs like [Cloudflare's Hibernation WebSocket](https://developers.cloudflare.com/durable-objects/best-practices/websockets/#durable-objects-hibernation-websocket-api).
47
48
  - [@orpc/json-schema](https://www.npmjs.com/package/@orpc/json-schema): Smart coercion for OpenAPI requests.
48
49
 
49
50
  **Framework & ecosystem integrations**
@@ -114,6 +115,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
114
115
  </tr>
115
116
  <tr>
116
117
  <td align="center"><a href="https://github.com/itigoore01?ref=orpc" target="_blank" rel="noopener" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&amp;v=4" width="139" alt="shota"/><br />shota</a></td>
118
+ <td align="center"><a href="https://github.com/ellis-driscoll?ref=orpc" target="_blank" rel="noopener" title="Ellis Driscoll"><img src="https://avatars.githubusercontent.com/u/70685966?u=c5f95bc33b5991d9744abe00052542e4a2ed3cb9&amp;v=4" width="139" alt="Ellis Driscoll"/><br />Ellis Driscoll</a></td>
117
119
  </tr>
118
120
  </table>
119
121
 
@@ -139,8 +141,9 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
139
141
  <td align="center"><a href="https://github.com/mr-kelly?ref=orpc" target="_blank" rel="noopener" title="Kelly Peilin Chan"><img src="https://avatars.githubusercontent.com/u/520852?u=6b0f7105f694e7b5cacf410a3f04c7044b469dc8&amp;v=4" width="119" alt="Kelly Peilin Chan"/><br />Kelly Peilin Chan</a></td>
140
142
  </tr>
141
143
  <tr>
144
+ <td align="center"><a href="https://github.com/guyariely?ref=orpc" target="_blank" rel="noopener" title="Guy Ariely"><img src="https://avatars.githubusercontent.com/u/42813496?u=edb6b7f563bf28e160a290832e7da57c0506f8ca&amp;v=4" width="119" alt="Guy Ariely"/><br />Guy Ariely</a></td>
142
145
  <td align="center"><a href="https://github.com/piscis?ref=orpc" target="_blank" rel="noopener" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&amp;v=4" width="119" alt="Alex"/><br />Alex</a></td>
143
- <td align="center"><a href="https://github.com/finom?ref=orpc" target="_blank" rel="noopener" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=29e91400dbd4a9c217048a8f59562c4f740498e6&amp;v=4" width="119" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
146
+ <td align="center"><a href="https://github.com/finom?ref=orpc" target="_blank" rel="noopener" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=c5f2daf7ebece498e85c83367bb37b4e10e2649d&amp;v=4" width="119" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
144
147
  </tr>
145
148
  </table>
146
149
 
@@ -1,4 +1,4 @@
1
- import { R as RateLimiter, a as RateLimitOptions, b as RateLimitResult } from '../shared/ratelimit.BtcMexUf.mjs';
1
+ import { R as RateLimiter, a as RateLimitOptions, b as RateLimitResult } from '../shared/ratelimit.DwqoOfMm.mjs';
2
2
 
3
3
  interface MemoryRateLimiterOptions {
4
4
  /**
@@ -27,6 +27,12 @@ interface MemoryRateLimiterOptions {
27
27
  timeout: number;
28
28
  };
29
29
  }
30
+ /**
31
+ * Rate limiter adapter backed by in-memory storage. Enforces a fixed-window
32
+ * limit, with optional blocking mode.
33
+ *
34
+ * @see {@link https://orpc.dev/docs/helpers/ratelimit#adapters | Rate Limit Helpers - Adapters}
35
+ */
30
36
  declare class MemoryRateLimiter implements RateLimiter {
31
37
  private readonly maxRequests;
32
38
  private readonly window;
@@ -1,4 +1,4 @@
1
- import { R as RateLimiter, a as RateLimitOptions, b as RateLimitResult } from '../shared/ratelimit.BtcMexUf.js';
1
+ import { R as RateLimiter, a as RateLimitOptions, b as RateLimitResult } from '../shared/ratelimit.DwqoOfMm.js';
2
2
 
3
3
  interface MemoryRateLimiterOptions {
4
4
  /**
@@ -27,6 +27,12 @@ interface MemoryRateLimiterOptions {
27
27
  timeout: number;
28
28
  };
29
29
  }
30
+ /**
31
+ * Rate limiter adapter backed by in-memory storage. Enforces a fixed-window
32
+ * limit, with optional blocking mode.
33
+ *
34
+ * @see {@link https://orpc.dev/docs/helpers/ratelimit#adapters | Rate Limit Helpers - Adapters}
35
+ */
30
36
  declare class MemoryRateLimiter implements RateLimiter {
31
37
  private readonly maxRequests;
32
38
  private readonly window;
@@ -1,5 +1,5 @@
1
1
  import { RedisClientType } from 'redis';
2
- import { R as RateLimiter, a as RateLimitOptions, b as RateLimitResult } from '../shared/ratelimit.BtcMexUf.mjs';
2
+ import { R as RateLimiter, a as RateLimitOptions, b as RateLimitResult } from '../shared/ratelimit.DwqoOfMm.mjs';
3
3
 
4
4
  interface RedisRateLimiterOptions {
5
5
  /**
@@ -34,6 +34,12 @@ interface RedisRateLimiterOptions {
34
34
  timeout: number;
35
35
  };
36
36
  }
37
+ /**
38
+ * Rate limiter adapter for Redis. Enforces a fixed-window limit using a
39
+ * Redis Lua script, with optional blocking mode.
40
+ *
41
+ * @see {@link https://orpc.dev/docs/helpers/ratelimit#adapters | Rate Limit Helpers - Adapters}
42
+ */
37
43
  declare class RedisRateLimiter implements RateLimiter {
38
44
  private readonly redis;
39
45
  private readonly prefix;
@@ -1,5 +1,5 @@
1
1
  import { RedisClientType } from 'redis';
2
- import { R as RateLimiter, a as RateLimitOptions, b as RateLimitResult } from '../shared/ratelimit.BtcMexUf.js';
2
+ import { R as RateLimiter, a as RateLimitOptions, b as RateLimitResult } from '../shared/ratelimit.DwqoOfMm.js';
3
3
 
4
4
  interface RedisRateLimiterOptions {
5
5
  /**
@@ -34,6 +34,12 @@ interface RedisRateLimiterOptions {
34
34
  timeout: number;
35
35
  };
36
36
  }
37
+ /**
38
+ * Rate limiter adapter for Redis. Enforces a fixed-window limit using a
39
+ * Redis Lua script, with optional blocking mode.
40
+ *
41
+ * @see {@link https://orpc.dev/docs/helpers/ratelimit#adapters | Rate Limit Helpers - Adapters}
42
+ */
37
43
  declare class RedisRateLimiter implements RateLimiter {
38
44
  private readonly redis;
39
45
  private readonly prefix;
@@ -1,5 +1,5 @@
1
1
  import { Ratelimit } from '@upstash/ratelimit';
2
- import { R as RateLimiter, a as RateLimitOptions, b as RateLimitResult } from '../shared/ratelimit.BtcMexUf.mjs';
2
+ import { R as RateLimiter, a as RateLimitOptions, b as RateLimitResult } from '../shared/ratelimit.DwqoOfMm.mjs';
3
3
 
4
4
  interface UpstashRateLimiterOptions {
5
5
  /**
@@ -26,6 +26,12 @@ interface UpstashRateLimiterOptions {
26
26
  */
27
27
  waitUntil?: (promise: Promise<any>) => any;
28
28
  }
29
+ /**
30
+ * Rate limiter adapter for Upstash Rate Limit. Delegates limit checks to a
31
+ * configured `Ratelimit` instance, with optional blocking mode.
32
+ *
33
+ * @see {@link https://orpc.dev/docs/helpers/ratelimit#adapters | Rate Limit Helpers - Adapters}
34
+ */
29
35
  declare class UpstashRateLimiter implements RateLimiter {
30
36
  private readonly ratelimit;
31
37
  private blockingUntilReady;
@@ -1,5 +1,5 @@
1
1
  import { Ratelimit } from '@upstash/ratelimit';
2
- import { R as RateLimiter, a as RateLimitOptions, b as RateLimitResult } from '../shared/ratelimit.BtcMexUf.js';
2
+ import { R as RateLimiter, a as RateLimitOptions, b as RateLimitResult } from '../shared/ratelimit.DwqoOfMm.js';
3
3
 
4
4
  interface UpstashRateLimiterOptions {
5
5
  /**
@@ -26,6 +26,12 @@ interface UpstashRateLimiterOptions {
26
26
  */
27
27
  waitUntil?: (promise: Promise<any>) => any;
28
28
  }
29
+ /**
30
+ * Rate limiter adapter for Upstash Rate Limit. Delegates limit checks to a
31
+ * configured `Ratelimit` instance, with optional blocking mode.
32
+ *
33
+ * @see {@link https://orpc.dev/docs/helpers/ratelimit#adapters | Rate Limit Helpers - Adapters}
34
+ */
29
35
  declare class UpstashRateLimiter implements RateLimiter {
30
36
  private readonly ratelimit;
31
37
  private blockingUntilReady;
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Context, MiddlewareOptions, Middleware } from '@orpc/server';
2
2
  import { StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
3
- import { b as RateLimitResult, R as RateLimiter } from './shared/ratelimit.BtcMexUf.mjs';
4
- export { a as RateLimitOptions } from './shared/ratelimit.BtcMexUf.mjs';
3
+ import { b as RateLimitResult, R as RateLimiter } from './shared/ratelimit.DwqoOfMm.mjs';
4
+ export { a as RateLimitOptions } from './shared/ratelimit.DwqoOfMm.mjs';
5
5
  import { Value, Promisable } from '@orpc/shared';
6
6
 
7
7
  declare const RATELIMIT_HANDLER_PLUGIN_CONTEXT_SYMBOL: unique symbol;
@@ -14,10 +14,10 @@ interface RateLimitHandlerPluginContext {
14
14
  };
15
15
  }
16
16
  /**
17
- * Automatically adds HTTP rate-limiting headers (RateLimit-* and Retry-After) to responses
18
- * when used with middleware created by createRatelimitMiddleware.
17
+ * Automatically adds HTTP rate limiting headers (`RateLimit-*` and `Retry-After`)
18
+ * to responses when used with the `ratelimit` middleware.
19
19
  *
20
- * @see {@link https://orpc.dev/docs/helpers/ratelimit#handler-plugin Ratelimit handler plugin}
20
+ * @see {@link https://orpc.dev/docs/helpers/ratelimit#handler-plugin | Rate Limit Helpers - Handler Plugin}
21
21
  */
22
22
  declare class RateLimitHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
23
23
  name: string;
@@ -66,7 +66,7 @@ interface RateLimitMiddlewareOptions<TInContext extends Context, TInput> {
66
66
  * Creates a middleware that enforces rate limits in oRPC procedures.
67
67
  * Supports per-request deduplication and integrates with the ratelimit handler plugin.
68
68
  *
69
- * @see {@link https://orpc.dev/docs/helpers/ratelimit#createratelimitmiddleware Ratelimit middleware}
69
+ * @see {@link https://orpc.dev/docs/helpers/ratelimit#ratelimit-middleware | Rate Limit Helpers - Ratelimit Middleware}
70
70
  */
71
71
  declare function ratelimit<TInContext extends Context, TInput>({ dedupe, ...options }: RateLimitMiddlewareOptions<TInContext, TInput>): Middleware<TInContext, object, TInput, any, object>;
72
72
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Context, MiddlewareOptions, Middleware } from '@orpc/server';
2
2
  import { StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
3
- import { b as RateLimitResult, R as RateLimiter } from './shared/ratelimit.BtcMexUf.js';
4
- export { a as RateLimitOptions } from './shared/ratelimit.BtcMexUf.js';
3
+ import { b as RateLimitResult, R as RateLimiter } from './shared/ratelimit.DwqoOfMm.js';
4
+ export { a as RateLimitOptions } from './shared/ratelimit.DwqoOfMm.js';
5
5
  import { Value, Promisable } from '@orpc/shared';
6
6
 
7
7
  declare const RATELIMIT_HANDLER_PLUGIN_CONTEXT_SYMBOL: unique symbol;
@@ -14,10 +14,10 @@ interface RateLimitHandlerPluginContext {
14
14
  };
15
15
  }
16
16
  /**
17
- * Automatically adds HTTP rate-limiting headers (RateLimit-* and Retry-After) to responses
18
- * when used with middleware created by createRatelimitMiddleware.
17
+ * Automatically adds HTTP rate limiting headers (`RateLimit-*` and `Retry-After`)
18
+ * to responses when used with the `ratelimit` middleware.
19
19
  *
20
- * @see {@link https://orpc.dev/docs/helpers/ratelimit#handler-plugin Ratelimit handler plugin}
20
+ * @see {@link https://orpc.dev/docs/helpers/ratelimit#handler-plugin | Rate Limit Helpers - Handler Plugin}
21
21
  */
22
22
  declare class RateLimitHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
23
23
  name: string;
@@ -66,7 +66,7 @@ interface RateLimitMiddlewareOptions<TInContext extends Context, TInput> {
66
66
  * Creates a middleware that enforces rate limits in oRPC procedures.
67
67
  * Supports per-request deduplication and integrates with the ratelimit handler plugin.
68
68
  *
69
- * @see {@link https://orpc.dev/docs/helpers/ratelimit#createratelimitmiddleware Ratelimit middleware}
69
+ * @see {@link https://orpc.dev/docs/helpers/ratelimit#ratelimit-middleware | Rate Limit Helpers - Ratelimit Middleware}
70
70
  */
71
71
  declare function ratelimit<TInContext extends Context, TInput>({ dedupe, ...options }: RateLimitMiddlewareOptions<TInContext, TInput>): Middleware<TInContext, object, TInput, any, object>;
72
72
 
@@ -25,6 +25,12 @@ interface RateLimitOptions {
25
25
  */
26
26
  weight?: number;
27
27
  }
28
+ /**
29
+ * Standard interface for checking and enforcing rate limits.
30
+ * Implement it for custom strategies, or use one of the provided adapters.
31
+ *
32
+ * @see {@link https://orpc.dev/docs/helpers/ratelimit | Rate Limit Helpers}
33
+ */
28
34
  interface RateLimiter {
29
35
  limit(key: string, options?: RateLimitOptions): Promise<RateLimitResult>;
30
36
  }
@@ -25,6 +25,12 @@ interface RateLimitOptions {
25
25
  */
26
26
  weight?: number;
27
27
  }
28
+ /**
29
+ * Standard interface for checking and enforcing rate limits.
30
+ * Implement it for custom strategies, or use one of the provided adapters.
31
+ *
32
+ * @see {@link https://orpc.dev/docs/helpers/ratelimit | Rate Limit Helpers}
33
+ */
28
34
  interface RateLimiter {
29
35
  limit(key: string, options?: RateLimitOptions): Promise<RateLimitResult>;
30
36
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/ratelimit",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.23",
4
+ "version": "2.0.0-beta.25",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.dev",
7
7
  "repository": {
@@ -53,15 +53,14 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@standardserver/core": "^0.6.0",
57
- "@orpc/server": "2.0.0-beta.23",
58
- "@orpc/shared": "2.0.0-beta.23"
56
+ "@standardserver/core": "^0.7.1",
57
+ "@orpc/server": "2.0.0-beta.25",
58
+ "@orpc/shared": "2.0.0-beta.25"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@upstash/ratelimit": "^2.0.8",
62
- "@upstash/redis": "^1.38.0",
63
- "ioredis": "^5.9.1",
64
- "redis": "^6.0.1"
62
+ "@upstash/redis": "^1.38.1",
63
+ "redis": "^6.2.0"
65
64
  },
66
65
  "scripts": {
67
66
  "build": "unbuild",