@upstash/ratelimit 0.1.5-next.1 → 0.1.5

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/esm/multi.js CHANGED
@@ -26,8 +26,8 @@ export class MultiRegionRatelimit extends Ratelimit {
26
26
  limiter: config.limiter,
27
27
  ctx: {
28
28
  redis: config.redis,
29
- cache: config.ephermeralCache
30
- ? new Cache(config.ephermeralCache)
29
+ cache: config.ephemeralCache
30
+ ? new Cache(config.ephemeralCache)
31
31
  : undefined,
32
32
  },
33
33
  });
package/esm/ratelimit.js CHANGED
@@ -126,10 +126,10 @@ export class Ratelimit {
126
126
  this.ctx = config.ctx;
127
127
  this.limiter = config.limiter;
128
128
  this.prefix = config.prefix ?? "@upstash/ratelimit";
129
- if (config.ephermeralCache instanceof Map) {
130
- this.ctx.cache = new Cache(config.ephermeralCache);
129
+ if (config.ephemeralCache instanceof Map) {
130
+ this.ctx.cache = new Cache(config.ephemeralCache);
131
131
  }
132
- else if (typeof config.ephermeralCache === "undefined") {
132
+ else if (typeof config.ephemeralCache === "undefined") {
133
133
  this.ctx.cache = new Cache(new Map());
134
134
  }
135
135
  }
package/esm/single.js CHANGED
@@ -26,7 +26,7 @@ export class RegionRatelimit extends Ratelimit {
26
26
  ctx: {
27
27
  redis: config.redis,
28
28
  },
29
- ephermeralCache: config.ephermeralCache,
29
+ ephemeralCache: config.ephemeralCache,
30
30
  });
31
31
  }
32
32
  /**
package/package.json CHANGED
@@ -3,6 +3,7 @@
3
3
  "main": "./script/mod.js",
4
4
  "types": "./types/mod.d.ts",
5
5
  "name": "@upstash/ratelimit",
6
+ "version": "v0.1.5",
6
7
  "description": "A serverless ratelimiter built on top of Upstash REST API.",
7
8
  "repository": {
8
9
  "type": "git",
@@ -46,6 +47,5 @@
46
47
  "require": "./script/mod.js",
47
48
  "types": "./types/mod.d.ts"
48
49
  }
49
- },
50
- "version": "0.1.5-next.1"
50
+ }
51
51
  }
package/script/multi.js CHANGED
@@ -29,8 +29,8 @@ class MultiRegionRatelimit extends ratelimit_js_1.Ratelimit {
29
29
  limiter: config.limiter,
30
30
  ctx: {
31
31
  redis: config.redis,
32
- cache: config.ephermeralCache
33
- ? new cache_js_1.Cache(config.ephermeralCache)
32
+ cache: config.ephemeralCache
33
+ ? new cache_js_1.Cache(config.ephemeralCache)
34
34
  : undefined,
35
35
  },
36
36
  });
@@ -129,10 +129,10 @@ class Ratelimit {
129
129
  this.ctx = config.ctx;
130
130
  this.limiter = config.limiter;
131
131
  this.prefix = config.prefix ?? "@upstash/ratelimit";
132
- if (config.ephermeralCache instanceof Map) {
133
- this.ctx.cache = new cache_js_1.Cache(config.ephermeralCache);
132
+ if (config.ephemeralCache instanceof Map) {
133
+ this.ctx.cache = new cache_js_1.Cache(config.ephemeralCache);
134
134
  }
135
- else if (typeof config.ephermeralCache === "undefined") {
135
+ else if (typeof config.ephemeralCache === "undefined") {
136
136
  this.ctx.cache = new cache_js_1.Cache(new Map());
137
137
  }
138
138
  }
package/script/single.js CHANGED
@@ -29,7 +29,7 @@ class RegionRatelimit extends ratelimit_js_1.Ratelimit {
29
29
  ctx: {
30
30
  redis: config.redis,
31
31
  },
32
- ephermeralCache: config.ephermeralCache,
32
+ ephemeralCache: config.ephemeralCache,
33
33
  });
34
34
  }
35
35
  /**
package/types/cache.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { EphermeralCache } from "./types.js";
2
- export declare class Cache implements EphermeralCache {
1
+ import { EphemeralCache } from "./types.js";
2
+ export declare class Cache implements EphemeralCache {
3
3
  /**
4
4
  * Stores identifier -> reset (in milliseconds)
5
5
  */
package/types/multi.d.ts CHANGED
@@ -38,7 +38,7 @@ export declare type MultiRegionRatelimitConfig = {
38
38
  * If left undefined, a map is created automatically, but it can only work
39
39
  * if the map or th ratelimit instance is created outside your serverless function handler.
40
40
  */
41
- ephermeralCache?: Map<string, number> | false;
41
+ ephemeralCache?: Map<string, number> | false;
42
42
  };
43
43
  /**
44
44
  * Ratelimiter using serverless redis from https://upstash.com/
@@ -34,7 +34,7 @@ export declare type RatelimitConfig<TContext> = {
34
34
  * If left undefined, a map is created automatically, but it can only work
35
35
  * if the map or the ratelimit instance is created outside your serverless function handler.
36
36
  */
37
- ephermeralCache?: Map<string, number> | false;
37
+ ephemeralCache?: Map<string, number> | false;
38
38
  };
39
39
  /**
40
40
  * Ratelimiter using serverless redis from https://upstash.com/
package/types/single.d.ts CHANGED
@@ -41,7 +41,7 @@ export declare type RegionRatelimitConfig = {
41
41
  * If left undefined, a map is created automatically, but it can only work
42
42
  * if the map or the ratelimit instance is created outside your serverless function handler.
43
43
  */
44
- ephermeralCache?: Map<string, number> | false;
44
+ ephemeralCache?: Map<string, number> | false;
45
45
  };
46
46
  /**
47
47
  * Ratelimiter using serverless redis from https://upstash.com/
package/types/types.d.ts CHANGED
@@ -3,9 +3,9 @@ export interface Redis {
3
3
  sadd: (key: string, ...members: string[]) => Promise<number>;
4
4
  }
5
5
  /**
6
- * EphermeralCache is used to block certain identifiers right away in case they have already exceedd the ratelimit.
6
+ * EphemeralCache is used to block certain identifiers right away in case they have already exceedd the ratelimit.
7
7
  */
8
- export interface EphermeralCache {
8
+ export interface EphemeralCache {
9
9
  isBlocked: (identifier: string) => {
10
10
  blocked: boolean;
11
11
  reset: number;
@@ -14,11 +14,11 @@ export interface EphermeralCache {
14
14
  }
15
15
  export declare type RegionContext = {
16
16
  redis: Redis;
17
- cache?: EphermeralCache;
17
+ cache?: EphemeralCache;
18
18
  };
19
19
  export declare type MultiRegionContext = {
20
20
  redis: Redis[];
21
- cache?: EphermeralCache;
21
+ cache?: EphemeralCache;
22
22
  };
23
23
  export declare type Context = RegionContext | MultiRegionContext;
24
24
  export declare type RatelimitResponse = {
@@ -63,5 +63,5 @@ export declare type RatelimitResponse = {
63
63
  pending: Promise<unknown>;
64
64
  };
65
65
  export declare type Algorithm<TContext> = (ctx: TContext, identifier: string, opts?: {
66
- cache?: EphermeralCache;
66
+ cache?: EphemeralCache;
67
67
  }) => Promise<RatelimitResponse>;