跳到正文
TakoAPI
返回技能列表

rate-limit-pro

由 raghulpasupathi 提供

Coding Agents & IDEs
419下载量由 clawskills.sh 提供
0浏览量
0 个赞登录后即可为这个技能点赞
—暂无评分
你的评分

简介

Advanced rate limiting with tiered controls and quota management.

描述

该技能的功能

Rate Limit Pro is a JavaScript class that enforces per-user request quotas using sliding time windows and configurable tiers. It tracks request timestamps in memory and returns remaining quota, reset timing, and denial reasons on each check.

It handles sliding window tracking and multi-tier quota management in a single in-memory class with no external dependencies like Redis.

何时使用

  • Enforcing free-tier request caps in a multi-tenant API
  • Blocking abusive users before they exhaust shared resources
  • Differentiating access between free and paid plan users
  • Preventing burst traffic from a single user ID
  • Testing rate limit logic in a local dev environment

示例工作流

输入

User asks: check if user123 can make another request on the free tier

智能体
  1. 1

    Instantiate RateLimiter with free tier set to 10 requests per 60 seconds

  2. 2

    Call checkLimit('user123', 'free') to evaluate the current request count

  3. 3

    Filter out timestamps older than the 60-second window

  4. 4

    Return allowed status with remaining count, or denial reason with resetIn seconds

输出

{ allowed: true, limit: 10, remaining: 7, resetIn: 60 } or { allowed: false, reason: 'rate_limit_exceeded', resetIn: 23 }

安装

clawhub install raghulpasupathi/rate-limit-pro

运行 CLI 命令,或把这段提示词粘贴到 Claude Code、Cursor、Codex 或你在用的任意编程智能体里。

链接