Skip to content

Module: Rate Limiting

Composable rate limiting with pluggable algorithms and state stores. Ships with token bucket, sliding window, and fixed window algorithms. In-memory store for development, Redis for distributed deployments. Includes middleware factories for Hono and Express.

Namemodule-rate-limit-ts
Version0.1.0
Categorycomposable-modules
LicenseApache-2.0
Personaengineering
Tagsrate-limit, throttle, middleware, typescript
Sourcetemplates/module-rate-limit-ts

Render it

Three front doors, one catalog. Pick whichever suits the caller.

# CLI
npx @nanohype/sdk render module-rate-limit-ts --out ./my-app

# SDK
import { LocalSource, renderTemplate } from "@nanohype/sdk";
const result = await renderTemplate(source, "module-rate-limit-ts", variables);

# MCP — from an agent
get_template({ name: "module-rate-limit-ts" })

Prerequisites

ToolVersionWhy
node>=22Node.js runtime for the rate limiting module

Variables

Required

ProjectName string
Kebab-case project name, used as package name and directory Must be lowercase kebab-case starting with a letter.

Optional

Description string — defaults to Rate limiting middleware with pluggable algorithms
Short project description for package.json and README
Algorithm string — defaults to token-bucket
Default rate limiting algorithm (token-bucket, sliding-window, fixed-window, or a custom name)
Store string — defaults to memory
Default state store for rate limit counters (memory, redis, or a custom name)

What it produces

24 files. Placeholder names such as __APP_NAME__ are what the renderer substitutes into.

.env.example
.gitignore
biome.json
package.json
src/rate-limit/__tests__/memory-store.test.ts
src/rate-limit/__tests__/registry.test.ts
src/rate-limit/__tests__/token-bucket.test.ts
src/rate-limit/algorithms/fixed-window.ts
src/rate-limit/algorithms/index.ts
src/rate-limit/algorithms/registry.ts
src/rate-limit/algorithms/sliding-window.ts
src/rate-limit/algorithms/token-bucket.ts
src/rate-limit/algorithms/types.ts
src/rate-limit/bootstrap.ts
src/rate-limit/index.ts
src/rate-limit/middleware.ts
src/rate-limit/stores/index.ts
src/rate-limit/stores/memory.ts
src/rate-limit/stores/redis.ts
src/rate-limit/stores/registry.ts
src/rate-limit/stores/types.ts
src/rate-limit/types.ts
tsconfig.json
vitest.config.ts

Composes with

Composites that use it

  • Production API Service — Production-grade TypeScript API service with auth, database, caching, rate limiting, background jobs, observability, and deployment..