npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@croco/ratelimit-core

v0.0.2

Published

고정 윈도우, 슬라이딩 윈도우, 토큰 버킷 알고리즘을 제공하는 레이트 리밋 코어 패키지입니다.

Readme

@croco/ratelimit-core

고정 윈도우, 슬라이딩 윈도우, 토큰 버킷 알고리즘을 제공하는 레이트 리밋 코어 패키지입니다.

설치

pnpm add @croco/ratelimit-core

사용법

import {
  RateLimiter,
  SlidingWindowInMemoryStore,
  createSlidingWindowPolicy,
} from "@croco/ratelimit-core";

const store = new SlidingWindowInMemoryStore();
const rateLimiter = new RateLimiter(store, (context) => String(context.get("userId")));

const result = await rateLimiter.check(context, createSlidingWindowPolicy("api", 100, 60_000));
import { RateLimit } from "@croco/ratelimit-core";

class ApiController {
  @RateLimit({ limit: 20, window: "1m", algorithm: "sliding" })
  async list(): Promise<void> {}
}

API 레퍼런스

핵심 클래스

  • RateLimiter, 정책 평가와 저장소 오류 처리까지 담당하는 핵심 서비스입니다.
  • RateLimitGuard, 라우트 메타데이터를 읽어 요청을 차단합니다.
  • RateLimitKeyBuilder, tenant, user, ip, route 조합으로 키를 생성합니다.

저장소 구현체

  • FixedWindowInMemoryStore, SlidingWindowInMemoryStore, TokenBucketInMemoryStore
  • RateLimitStore, DistributedRateLimitStore, FixedWindowStore, SlidingWindowStore, TokenBucketStore

정책과 미들웨어

  • createFixedWindowPolicy, createSlidingWindowPolicy, createTokenBucketPolicy
  • createRateLimitMiddleware, HTTP 미들웨어 생성 헬퍼입니다.
  • @RateLimit, 메서드 데코레이터 기반 보호 기능입니다.

주요 타입과 문제 타입

  • RateLimitPolicy, RateLimitResult, RateLimitStats, RateLimitAlgorithm
  • RateLimitDecoratorOptions, RateLimitMetadata, RateLimitHeaders, HttpContext
  • 문제 타입: RateLimitExceededProblem, RateLimitWindowProblem, RateLimitKeyBuilderProblem

구현 포인트

  • 분산 저장소가 필요하면 RateLimitStore 계층을 상속해 Redis, Upstash 등으로 확장합니다.
  • failOpen 옵션으로 저장소 장애 시 허용 전략을 선택할 수 있습니다.
  • 윈도우 문자열은 1s, 1m, 1h, 1d 형식을 사용합니다.