HttpProtect.(constructor)
Resolves every threshold, parses the exempt networks and connects to Redis.
Signature:
constructor(options?: HttpProtectOptions | undefined);
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
options |
HttpProtectOptions | undefined |
(Optional) configuration; every field is optional, and omitting the object entirely gives default thresholds against |
Exceptions
TypeError if any HttpProtectOptions.safeNetworks entry is not valid CIDR — including a bare address with no prefix length.
Remarks
Connects immediately unless HttpProtectOptions.redis is supplied, so this is not a cheap object to build in a process that has no Redis.
Example
const protect = new HttpProtect({
redis: existingClient,
ttl: 60,
maxRequests: 600,
banLimit: 10000,
safeNetworks: ['10.0.0.0/8', '203.0.113.7/32'],
});
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.