@clov-std/elysia-ratelimit 3.1.0 → 3.1.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/dist/index.js CHANGED
@@ -45,7 +45,11 @@ var extractClientIp = (request, server) => {
45
45
  return request.headers.get("x-real-ip") ?? server?.requestIP(request)?.address ?? "127.0.0.1";
46
46
  };
47
47
  var rateLimitPlugin = (store = new MemoryStore) => new Elysia().macro({
48
- rateLimit: ({ limit, window, keyGenerator }) => ({
48
+ rateLimit: ({
49
+ limit,
50
+ window,
51
+ keyGenerator
52
+ }) => ({
49
53
  response: { 429: rateLimitResponseSchema },
50
54
  transform: async ({ set, request, server }) => {
51
55
  const route = `${request.method}:${new URL(request.url).pathname}`;
@@ -2,6 +2,7 @@ import { Exception } from '@clov-std/error';
2
2
  import { type KvStore } from '@clov-std/kv-store';
3
3
  import type { Server } from 'bun';
4
4
  import { Elysia, type HTTPHeaders } from 'elysia';
5
+ import type { TLiteral, TObject, TOptional, TString } from 'typebox/type';
5
6
  export declare const RATE_LIMIT_ERROR_KEYS: {
6
7
  readonly RATE_LIMIT_EXCEEDED: 'elysia-ratelimit.exceeded';
7
8
  };
@@ -17,11 +18,11 @@ export interface RateLimitExceeded {
17
18
  /**
18
19
  * Shape of the `429` body, following RFC 9457.
19
20
  */
20
- declare const rateLimitResponseSchema: import("typebox").TObject<{
21
- type: import("typebox").TString;
22
- title: import("typebox").TString;
23
- status: import("typebox").TLiteral<429>;
24
- detail: import("typebox").TOptional<import("typebox").TString>;
21
+ declare const rateLimitResponseSchema: TObject<{
22
+ type: TString;
23
+ title: TString;
24
+ status: TLiteral<429>;
25
+ detail: TOptional<TString>;
25
26
  }>;
26
27
  /**
27
28
  * Thrown when a caller exceeds its allowance.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clov-std/elysia-ratelimit",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Rate limiting plugin for Elysia framework.",
5
5
  "keywords": [
6
6
  "bun",