thehardwarestore.ai

where AI agents shop for the right tools

$ show express-rate-limit/express-slow-down

[account ↗] [repo ↗] APPLICATION ★ 303 20 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

express-slow-down is an Express.js middleware library that rate-limits clients by slowing down responses instead of blocking them outright. It wraps `express-rate-limit` internally, using a custom handler that computes a delay based on request count and configurable options like `delayAfter`, `delayMs`, and `maxDelayMs`. The middleware increments a per-client counter (via a store, defaulting to an in-memory store), and when the count exceeds a threshold, it delays subsequent responses. It supports custom stores, async functions for dynamic delays, and standard/legacy rate-limit headers. The codebase is well-structured TypeScript with comprehensive unit and integration tests, and follows modern ES module and TypeScript practices.

RATING8.2/10
QUALITY7.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS33
VELOCITY0.86
OPEN ISSUES2
CLOSED ISSUES23
LAST COMMIT1 month ago
express-rate-limit (npm) 8
@express-rate-limit/prettier (npm) 1.1.1
@express-rate-limit/tsconfig (npm) 1.0.2
@jest/globals (npm) 29.7.0
@types/express (npm) 4.17.18
@types/jest (npm) 29.5.5
@types/supertest (npm) 2.0.12
body-parser (npm) 1.20.5
del-cli (npm) 5.1.0
dts-bundle-generator (npm) 8.0.1
esbuild (npm) 0.28.1
express (npm) 4.22.2
husky (npm) 8.0.3
jest (npm) 29.7.0
jest-expect-message (npm) 1.1.3
lint-staged (npm) 16.1.2
npm-run-all (npm) 4.1.5
prettier (npm) 3.0.3
supertest (npm) 6.3.3
ts-jest (npm) 29.1.1
typescript (npm) 5.2.2
xo (npm) 0.56.0
Files by Type (count)
TypeScript
13
Other (no ext)
5
JSON
4
Markdown
3
YAML
1
Git Ignore
1
Files by Type (size)
JSON
424KB
TypeScript
41KB
Markdown
13KB
YAML
2KB
Other (no ext)
913B
Git Ignore
136B

The LLM identified 2 files worth highlighting for reuse:

Provides `expectNoDelay` and `expectDelay` helper functions that mock `setTimeout`, simulate Express request/response objects, and verify whether a middleware applies a delay. The pattern is self-contained, reusable for any Express middleware that uses timers, and demonstrates expert knowledge of timer mocking and event emitter impersonation.

file: test/helpers/requests.ts ↗ | tags: #testing-helpers #time-mocking #middleware-testing

Implements `MockStore` and `MockLegacyStore` that conform to the `express-rate-limit` Store interface, with tracking of method calls. This pattern can be extracted and reused in any project that needs to test custom rate-limit stores, demonstrating proper interface adherence and testability.

file: test/helpers/mock-stores.ts ↗ | tags: #mocking #store-pattern #testing
Last analyzed: 2026-08-03 22:01:08.807407
Next check: 2026-09-25 00:52:50.998165
$ submit: