@alxia/rate-limit 0.4.0 → 0.4.1

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
@@ -63,12 +63,12 @@ app.use(rateLimit({ limit: 100, windowMs: 60_000, store: redisStore(redis, { nam
63
63
 
64
64
  A store that counts by a rate of its own declares it as `policy: { limit,
65
65
  windowMs }`, and `rateLimit({ store })` reads both from it, headers included:
66
- the numbers are written once. `redisStore(handle.limits.api, api)` does, from
67
- the definition `api`. A `limit` or `windowMs` given beside it that differs
66
+ the numbers are written once. `redisStore(handle.limits.api)` does, from
67
+ the bound limit's definition. A `limit` or `windowMs` given beside it that differs
68
68
  throws at declaration.
69
69
 
70
70
  ```ts
71
- app.use(rateLimit({ store: redisStore(handle.limits.api, api) }));
71
+ app.use(rateLimit({ store: redisStore(handle.limits.api) }));
72
72
  ```
73
73
 
74
74
  A store of your own implements `RateLimitStore` (and, to count by a rate of
package/docs/guide.md CHANGED
@@ -80,7 +80,7 @@ written once. Without one they are required, and a type error says so.
80
80
  import { redisStore } from '@alxia/redis';
81
81
 
82
82
  // `api` is the defineRateLimit definition the handle wired.
83
- app.use(rateLimit({ store: redisStore(handle.limits.api, api) })); // 100 per 60 s, from `api`
83
+ app.use(rateLimit({ store: redisStore(handle.limits.api) })); // 100 per 60 s, from `api`
84
84
  ```
85
85
 
86
86
  A `limit` or a `windowMs` given beside a policy must equal it, or
package/docs/roadmap.md CHANGED
@@ -39,7 +39,7 @@ Nothing scheduled yet.
39
39
  reads `limit` and `windowMs` from it, both optional in the type, headers
40
40
  included; without a policy they stay required. A `limit` or `windowMs` that
41
41
  differs from the policy throws at declaration. `@alxia/redis`'s
42
- `redisStore(handle.limits.api, api)` is such a store. Every existing form
42
+ `redisStore(handle.limits.api)` is such a store. Every existing form
43
43
  works as before.
44
44
 
45
45
  ### 0.1.0
@@ -132,7 +132,7 @@ app.use(rateLimit({ limit: Number(Bun.env.RATE_LIMIT ?? 100), windowMs: 60_000 }
132
132
  ### `TypeError: rateLimit: limit … differs from the store's policy of …`
133
133
 
134
134
  **When:** `rateLimit()` is given a `store` that declares its own `policy`
135
- (`redisStore(handle.limits.api, api)`) and a `limit` or a `windowMs` that is
135
+ (`redisStore(handle.limits.api)`) and a `limit` or a `windowMs` that is
136
136
  not the store's. It throws at declaration, so the app fails at startup:
137
137
 
138
138
  ```text
@@ -147,7 +147,7 @@ say what the store does not enforce. (`windowMs` reads the same way.)
147
147
  the rate, change the definition the store reads it from:
148
148
 
149
149
  ```ts
150
- app.use(rateLimit({ store: redisStore(handle.limits.api, api) }));
150
+ app.use(rateLimit({ store: redisStore(handle.limits.api) }));
151
151
  ```
152
152
 
153
153
  ## Responses
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alxia/rate-limit",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Rate limiting for alxia: a 429 with Retry-After past the limit, the remaining allowance typed in the context, pluggable stores",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,12 +41,12 @@
41
41
  ]
42
42
  },
43
43
  "devDependencies": {
44
- "@alxia/core": "^0.5.0",
44
+ "@alxia/core": "^0.5.1",
45
45
  "@types/bun": "^1.4.2",
46
46
  "zod": "^4.2.0"
47
47
  },
48
48
  "peerDependencies": {
49
- "@alxia/core": "^0.5.0",
49
+ "@alxia/core": "^0.5.1",
50
50
  "typescript": "^6.0.3 || ^7.0.0"
51
51
  }
52
52
  }