@clov-std/elysia-ratelimit 4.0.15-rc.1 → 4.0.16
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/dist/index.js +1 -5
- package/dist/rate-limit.d.ts +5 -6
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -29,11 +29,7 @@ var extractClientIp = (request, server) => {
|
|
|
29
29
|
return request.headers.get("x-real-ip") ?? server?.requestIP(request)?.address ?? "127.0.0.1";
|
|
30
30
|
};
|
|
31
31
|
var rateLimitPlugin = (store = new MemoryStore) => new Elysia({ name: "rateLimitPlugin" }).macro({
|
|
32
|
-
rateLimit: ({
|
|
33
|
-
limit,
|
|
34
|
-
window,
|
|
35
|
-
keyGenerator
|
|
36
|
-
}) => ({
|
|
32
|
+
rateLimit: ({ limit, window, keyGenerator }) => ({
|
|
37
33
|
response: { 429: rateLimitResponseSchema },
|
|
38
34
|
transform: async ({ set, request, server }) => {
|
|
39
35
|
const route = `${request.method}:${new URL(request.url).pathname}`;
|
package/dist/rate-limit.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type KvStore } from '@clov-std/kv-store';
|
|
2
2
|
import type { Server } from 'bun';
|
|
3
3
|
import { Elysia, type HTTPHeaders } from 'elysia';
|
|
4
|
-
import type { TLiteral, TObject, TString } from 'typebox/type';
|
|
5
4
|
export declare const RATE_LIMIT_ERROR_CODES: {
|
|
6
5
|
readonly QUOTA_EXCEEDED: 'rate-limit.quota.exceeded';
|
|
7
6
|
};
|
|
@@ -11,11 +10,11 @@ export declare const RATE_LIMIT_ERROR_CODES: {
|
|
|
11
10
|
* `title` is filled by Elysia from the status reason phrase, so the plugin only supplies
|
|
12
11
|
* `type`, `status`, and `detail`.
|
|
13
12
|
*/
|
|
14
|
-
declare const rateLimitResponseSchema: TObject<{
|
|
15
|
-
type: TString;
|
|
16
|
-
title: TString;
|
|
17
|
-
status: TLiteral<429>;
|
|
18
|
-
detail: TString;
|
|
13
|
+
declare const rateLimitResponseSchema: import("typebox").TObject<{
|
|
14
|
+
type: import("typebox").TString;
|
|
15
|
+
title: import("typebox").TString;
|
|
16
|
+
status: import("typebox").TLiteral<429>;
|
|
17
|
+
detail: import("typebox").TString;
|
|
19
18
|
}>;
|
|
20
19
|
export interface RateLimitKeyContext {
|
|
21
20
|
request: Request;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clov-std/elysia-ratelimit",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.16",
|
|
4
4
|
"description": "Rate limiting plugin for Elysia framework.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -40,17 +40,17 @@
|
|
|
40
40
|
"test": "bun test --pass-with-no-tests --coverage"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@clov-std/kv-store": "^2.0.
|
|
43
|
+
"@clov-std/kv-store": "^2.0.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/bun": "^1.4.2",
|
|
47
|
-
"oxfmt": "0.
|
|
48
|
-
"oxlint": "1.
|
|
49
|
-
"oxlint-tsgolint": "7.0.
|
|
47
|
+
"oxfmt": "0.72.0",
|
|
48
|
+
"oxlint": "1.87.0",
|
|
49
|
+
"oxlint-tsgolint": "7.0.2004",
|
|
50
50
|
"typescript": "^7.0.2"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@clov-std/kv-store": "^2.0.
|
|
53
|
+
"@clov-std/kv-store": "^2.0.2",
|
|
54
54
|
"elysia": "next",
|
|
55
55
|
"typebox": "^1.3.36"
|
|
56
56
|
}
|