@upstash/ratelimit
Advanced tools
Comparing version 0.1.4-rc.1 to 0.1.4
@@ -29,3 +29,5 @@ import { ms } from "./duration.js"; | ||
redis: config.redis, | ||
cache: config.ephermeralCache ? new Cache() : undefined, | ||
cache: config.ephermeralCache | ||
? new Cache(config.ephermeralCache) | ||
: undefined, | ||
}, | ||
@@ -32,0 +34,0 @@ }); |
@@ -204,4 +204,2 @@ import { ms } from "./duration.js"; | ||
* than `refillRate` | ||
* | ||
* **Usage of Upstash Redis requests:** | ||
*/ | ||
@@ -208,0 +206,0 @@ static tokenBucket( |
@@ -6,3 +6,3 @@ { | ||
"name": "@upstash/ratelimit", | ||
"version": "v0.1.4-rc.1", | ||
"version": "v0.1.4", | ||
"description": "A serverless ratelimiter built on top of Upstash REST API.", | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -1,10 +0,8 @@ | ||
# Upstash Ratelimit | ||
# Upstash RateLimit | ||
An HTTP/REST based Redis client built on top of Upstash REST API. | ||
[Upstash REST API](https://docs.upstash.com/features/restapi). | ||
[![Tests](https://github.com/upstash/ratelimit/actions/workflows/tests.yaml/badge.svg)](https://github.com/upstash/ratelimit/actions/workflows/tests.yaml) | ||
![npm (scoped)](https://img.shields.io/npm/v/@upstash/ratelimit) | ||
It is the only connectionless (HTTP based) ratelimiter and designed for: | ||
It is the only connectionless (HTTP based) rate limiting library and designed | ||
for: | ||
@@ -21,2 +19,3 @@ - Serverless functions (AWS Lambda ...) | ||
- [Docs](#docs) | ||
- [Quick Start](#quick-start) | ||
@@ -29,3 +28,4 @@ - [Install](#install) | ||
- [Block until ready](#block-until-ready) | ||
- [MultiRegionly replicated ratelimiting](#multiregionly-replicated-ratelimiting) | ||
- [Ephemeral Cache](#ephemeral-cache) | ||
- [MultiRegion replicated ratelimiting](#multiregion-replicated-ratelimiting) | ||
- [Usage](#usage) | ||
@@ -54,2 +54,6 @@ - [Asynchronous synchronization between databases](#asynchronous-synchronization-between-databases) | ||
## Docs | ||
[doc.deno.land](https://doc.deno.land/https://deno.land/x/upstash_ratelimit/src/mod.ts) | ||
## Quick Start | ||
@@ -186,7 +190,6 @@ | ||
For extreme load or denial of service attacks, it might be too expensive to call | ||
redis for every incoming request, just to find out the request should be blocked | ||
because they have exceeded the limit. | ||
redis for every incoming request, just to find out it should be blocked because | ||
they have exceeded the limit. | ||
You can use an ephemeral in memory cache by passing the `ephemeralCache` | ||
options: | ||
You can use an ephemeral in memory cache by passing the `ephemeralCache` option: | ||
@@ -204,17 +207,14 @@ ```ts | ||
If enabled, the ratelimiter will keep a global cache of identifiers and a reset | ||
timestamp, that have exhausted their ratelimit. In serverless environments this | ||
is only possible if you create the ratelimiter instance outside of your handler | ||
function. While the function is still hot, the ratelimiter can block requests | ||
without having to request data from redis, thus saving time and money. | ||
If enabled, the ratelimiter will keep a global cache of identifiers and their | ||
reset timestamps, that have exhausted their ratelimit. In serverless | ||
environments this is only possible if you create the cache or ratelimiter | ||
instance outside of your handler function. While the function is still hot, the | ||
ratelimiter can block requests without having to request data from redis, thus | ||
saving time and money. | ||
Whenever an identifier has exceeded its limit, the ratelimiter will add it to an | ||
internal list together with its reset timestamp. If the same identifier makes a | ||
new request before it is reset, we can immediately reject it. | ||
## MultiRegion replicated ratelimiting | ||
## MultiRegionly replicated ratelimiting | ||
Using a single redis instance has the downside of providing low latencies to the | ||
part of your userbase closest to the deployed db. That's why we also built | ||
`MultiRegionRatelimit` which replicates the state across multiple redis | ||
Using a single redis instance has the downside of providing low latencies only | ||
to the part of your userbase closest to the deployed db. That's why we also | ||
built `MultiRegionRatelimit` which replicates the state across multiple redis | ||
databases as well as offering lower latencies to more of your users. | ||
@@ -286,3 +286,3 @@ | ||
Let's assume you have customers in the US and Europe. In this case you can | ||
create 2 regional redis databases on [Upastash](https://console.upstash.com) and | ||
create 2 regional redis databases on [Upstash](https://console.upstash.com) and | ||
your users will enjoy the latency of whichever db is closest to them. | ||
@@ -289,0 +289,0 @@ |
@@ -32,3 +32,5 @@ "use strict"; | ||
redis: config.redis, | ||
cache: config.ephermeralCache ? new cache_js_1.Cache() : undefined, | ||
cache: config.ephermeralCache | ||
? new cache_js_1.Cache(config.ephermeralCache) | ||
: undefined, | ||
}, | ||
@@ -35,0 +37,0 @@ }); |
@@ -207,4 +207,2 @@ "use strict"; | ||
* than `refillRate` | ||
* | ||
* **Usage of Upstash Redis requests:** | ||
*/ | ||
@@ -211,0 +209,0 @@ static tokenBucket( |
@@ -130,4 +130,2 @@ import type { Duration } from "./duration.js"; | ||
* than `refillRate` | ||
* | ||
* **Usage of Upstash Redis requests:** | ||
*/ | ||
@@ -134,0 +132,0 @@ static tokenBucket( |
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
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
82937
1927