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.
| Name | module-rate-limit-ts |
| Version | 0.1.0 |
| Category | composable-modules |
| License | Apache-2.0 |
| Persona | engineering |
| Tags | rate-limit, throttle, middleware, typescript |
| Source | templates/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
| Tool | Version | Why |
|---|---|---|
node | >=22 | Node.js runtime for the rate limiting module |
Variables
Required
ProjectNamestring- Kebab-case project name, used as package name and directory Must be lowercase kebab-case starting with a letter.
Optional
Descriptionstring — defaults toRate limiting middleware with pluggable algorithms- Short project description for package.json and README
Algorithmstring — defaults totoken-bucket- Default rate limiting algorithm (token-bucket, sliding-window, fixed-window, or a custom name)
Storestring — defaults tomemory- 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.tsComposes with
- Pairs with
ts-service - Pairs with
module-auth-ts - Nests inside
monorepo
Composites that use it
- Production API Service — Production-grade TypeScript API service with auth, database, caching, rate limiting, background jobs, observability, and deployment..