upstash/ratelimit-js — reverse-engineered prompt

Reverse engineered prompt

GitHub

Build me a TypeScript rate limiting library for apps that run in serverless and edge places like AWS Lambda, Vercel, Cloudflare Workers, Fastly, Next.js, and browser or mobile clients where HTTP is easier than normal Redis connections.

I want it to use Upstash Redis over REST, let people create a limiter with a simple setup, then call something like limit with an identifier such as an IP address, user id, api key, or one shared name. It should support a sliding window limit like 10 requests every 10 seconds, return whether the request is allowed, and optionally record analytics. Also let users set a custom key prefix so they can share the Redis database safely.

Please include clear install and usage docs, a basic example, a Next.js style example if it fits, and tests that can run with Upstash Redis URL and token environment variables. Look up current Upstash docs online if you need to.

Want more depth? Deep Reverse