@upstash/ratelimit
Advanced tools
Comparing version 0.1.5-next.1 to 0.1.5
@@ -29,4 +29,4 @@ import { ms } from "./duration.js"; | ||
redis: config.redis, | ||
cache: config.ephermeralCache | ||
? new Cache(config.ephermeralCache) | ||
cache: config.ephemeralCache | ||
? new Cache(config.ephemeralCache) | ||
: undefined, | ||
@@ -33,0 +33,0 @@ }, |
@@ -129,6 +129,6 @@ import { Cache } from "./cache.js"; | ||
this.prefix = config.prefix ?? "@upstash/ratelimit"; | ||
if (config.ephermeralCache instanceof Map) { | ||
this.ctx.cache = new Cache(config.ephermeralCache); | ||
if (config.ephemeralCache instanceof Map) { | ||
this.ctx.cache = new Cache(config.ephemeralCache); | ||
} | ||
else if (typeof config.ephermeralCache === "undefined") { | ||
else if (typeof config.ephemeralCache === "undefined") { | ||
this.ctx.cache = new Cache(new Map()); | ||
@@ -135,0 +135,0 @@ } |
@@ -29,3 +29,3 @@ import { ms } from "./duration.js"; | ||
}, | ||
ephermeralCache: config.ephermeralCache, | ||
ephemeralCache: config.ephemeralCache, | ||
}); | ||
@@ -32,0 +32,0 @@ } |
@@ -6,2 +6,3 @@ { | ||
"name": "@upstash/ratelimit", | ||
"version": "v0.1.5", | ||
"description": "A serverless ratelimiter built on top of Upstash REST API.", | ||
@@ -50,4 +51,3 @@ "repository": { | ||
} | ||
}, | ||
"version": "0.1.5-next.1" | ||
} | ||
} |
@@ -32,4 +32,4 @@ "use strict"; | ||
redis: config.redis, | ||
cache: config.ephermeralCache | ||
? new cache_js_1.Cache(config.ephermeralCache) | ||
cache: config.ephemeralCache | ||
? new cache_js_1.Cache(config.ephemeralCache) | ||
: undefined, | ||
@@ -36,0 +36,0 @@ }, |
@@ -132,6 +132,6 @@ "use strict"; | ||
this.prefix = config.prefix ?? "@upstash/ratelimit"; | ||
if (config.ephermeralCache instanceof Map) { | ||
this.ctx.cache = new cache_js_1.Cache(config.ephermeralCache); | ||
if (config.ephemeralCache instanceof Map) { | ||
this.ctx.cache = new cache_js_1.Cache(config.ephemeralCache); | ||
} | ||
else if (typeof config.ephermeralCache === "undefined") { | ||
else if (typeof config.ephemeralCache === "undefined") { | ||
this.ctx.cache = new cache_js_1.Cache(new Map()); | ||
@@ -138,0 +138,0 @@ } |
@@ -32,3 +32,3 @@ "use strict"; | ||
}, | ||
ephermeralCache: config.ephermeralCache, | ||
ephemeralCache: config.ephemeralCache, | ||
}); | ||
@@ -35,0 +35,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { EphermeralCache } from "./types.js"; | ||
export declare class Cache implements EphermeralCache { | ||
import { EphemeralCache } from "./types.js"; | ||
export declare class Cache implements EphemeralCache { | ||
/** | ||
@@ -4,0 +4,0 @@ * Stores identifier -> reset (in milliseconds) |
@@ -41,3 +41,3 @@ import type { Duration } from "./duration.js"; | ||
*/ | ||
ephermeralCache?: Map<string, number> | false; | ||
ephemeralCache?: Map<string, number> | false; | ||
}; | ||
@@ -44,0 +44,0 @@ /** |
@@ -37,3 +37,3 @@ import type { Algorithm, Context, RatelimitResponse } from "./types.js"; | ||
*/ | ||
ephermeralCache?: Map<string, number> | false; | ||
ephemeralCache?: Map<string, number> | false; | ||
}; | ||
@@ -40,0 +40,0 @@ /** |
@@ -44,3 +44,3 @@ import type { Duration } from "./duration.js"; | ||
*/ | ||
ephermeralCache?: Map<string, number> | false; | ||
ephemeralCache?: Map<string, number> | false; | ||
}; | ||
@@ -47,0 +47,0 @@ /** |
@@ -6,5 +6,5 @@ export interface Redis { | ||
/** | ||
* EphermeralCache is used to block certain identifiers right away in case they have already exceedd the ratelimit. | ||
* EphemeralCache is used to block certain identifiers right away in case they have already exceedd the ratelimit. | ||
*/ | ||
export interface EphermeralCache { | ||
export interface EphemeralCache { | ||
isBlocked: (identifier: string) => { | ||
@@ -18,7 +18,7 @@ blocked: boolean; | ||
redis: Redis; | ||
cache?: EphermeralCache; | ||
cache?: EphemeralCache; | ||
}; | ||
export declare type MultiRegionContext = { | ||
redis: Redis[]; | ||
cache?: EphermeralCache; | ||
cache?: EphemeralCache; | ||
}; | ||
@@ -68,3 +68,3 @@ export declare type Context = RegionContext | MultiRegionContext; | ||
export declare type Algorithm<TContext> = (ctx: TContext, identifier: string, opts?: { | ||
cache?: EphermeralCache; | ||
cache?: EphemeralCache; | ||
}) => Promise<RatelimitResponse>; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82907
1