CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-express-rate-limit

Express middleware for IP-based rate limiting with flexible configuration options and multiple storage backends

Overall
score

96%

Overview
Eval results
Files

task.mdevals/scenario-3/

Rate-Limited Message Service

Build a small HTTP service that rate-limits requests using the dependency's built-in in-memory store and exposes a cleanup hook.

Capabilities

Enforces windowed limit per client

  • Configure request limiting for GET /api/message so a client receives successful responses (status 200, JSON body with a message string) while under the configured limit for the window. @test
  • When the same client exceeds the configured limit inside the window, respond with status 429 and a JSON error payload; do not serve the normal response. @test
  • Rely on the dependency's default in-memory store rather than building or injecting a custom store. @test

Resets counts after window

  • After a client has been limited, waiting for the configured window duration resets their counters so the next request succeeds again. @test

Manual admin reset

  • POST /admin/reset accepts a JSON body with clientId; when provided, clear that client's counters immediately using the limiter's own reset mechanism and respond with 204. Missing clientId yields status 400. @test

Cleanup hook

  • Export a shutdown helper that stops the limiter's internal timers/intervals so tests can finish without lingering background work; calling it multiple times should be safe. @test

Implementation

@generates

API

export interface RateLimiterOptions {
  windowMs?: number;
  limit?: number;
}

export function createApp(options?: RateLimiterOptions): import('express').Express;

export function shutdown(app: import('express').Express): Promise<void>;

Dependencies { .dependencies }

express { .dependency }

HTTP routing and middleware for the server. @satisfied-by

express-rate-limit { .dependency }

Provides request limiting with the built-in in-memory store. @satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-express-rate-limit

tile.json