Socket
Socket
Sign inDemoInstall

rate-limiter-flexible

Package Overview
Dependencies
0
Maintainers
1
Versions
163
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.1 to 3.0.2

16

lib/index.d.ts

@@ -250,6 +250,10 @@ export interface IRateLimiterRes {

interface IRateLimiterPostgresOptions extends IRateLimiterStoreNoAutoExpiryOptions {
schemaName?: string;
}
interface IRateLimiterRedisOptions extends IRateLimiterStoreOptions {
rejectIfRedisNotReady?: boolean;
useRedisPackage?: boolean;
useRedis3AndLowerPackage?: boolean;
rejectIfRedisNotReady?: boolean;
useRedisPackage?: boolean;
useRedis3AndLowerPackage?: boolean;
}

@@ -287,3 +291,3 @@

export class RateLimiterRedis extends RateLimiterStoreAbstract {
constructor(opts: IRateLimiterRedisOptions);
constructor(opts: IRateLimiterRedisOptions);
}

@@ -347,6 +351,6 @@

export class RateLimiterPostgres extends RateLimiterStoreAbstract {
constructor(opts: IRateLimiterStoreNoAutoExpiryOptions, cb?: ICallbackReady);
constructor(opts: IRateLimiterPostgresOptions, cb?: ICallbackReady);
}
export class RateLimiterMemcache extends RateLimiterStoreAbstract {}
export class RateLimiterMemcache extends RateLimiterStoreAbstract { }

@@ -353,0 +357,0 @@ export class RateLimiterUnion {

@@ -17,2 +17,3 @@ const RateLimiterStoreAbstract = require('./RateLimiterStoreAbstract');

* tableName: 'string',
* schemaName: 'string', // optional
* }

@@ -27,2 +28,3 @@ */

this.tableName = opts.tableName;
this.schemaName = opts.schemaName;

@@ -57,2 +59,6 @@ this.clearExpiredByTimeout = opts.clearExpiredByTimeout;

_getTableIdentifier() {
return this.schemaName ? `"${this.schemaName}"."${this.tableName}"` : `"${this.tableName}"`;
}
clearExpired(expire) {

@@ -62,3 +68,3 @@ return new Promise((resolve) => {

name: 'rlflx-clear-expired',
text: `DELETE FROM "${this.tableName}" WHERE expire < $1`,
text: `DELETE FROM ${this._getTableIdentifier()} WHERE expire < $1`,
values: [expire],

@@ -157,3 +163,3 @@ };

_getCreateTableStmt() {
return `CREATE TABLE IF NOT EXISTS "${this.tableName}" (
return `CREATE TABLE IF NOT EXISTS ${this._getTableIdentifier()} (
key varchar(255) PRIMARY KEY,

@@ -198,4 +204,12 @@ points integer NOT NULL DEFAULT 0,

get schemaName() {
return this._schemaName;
}
set schemaName(value) {
this._schemaName = value;
}
get tableCreated() {
return this._tableCreated
return this._tableCreated;
}

@@ -261,4 +275,4 @@

: ` CASE
WHEN "${this.tableName}".expire <= $4 THEN $3
ELSE "${this.tableName}".expire
WHEN ${this._getTableIdentifier()}.expire <= $4 THEN $3
ELSE ${this._getTableIdentifier()}.expire
END `;

@@ -269,7 +283,7 @@

text: `
INSERT INTO "${this.tableName}" VALUES ($1, $2, $3)
INSERT INTO ${this._getTableIdentifier()} VALUES ($1, $2, $3)
ON CONFLICT(key) DO UPDATE SET
points = CASE
WHEN ("${this.tableName}".expire <= $4 OR 1=${forceExpire ? 1 : 0}) THEN $2
ELSE "${this.tableName}".points + ($2)
WHEN (${this._getTableIdentifier()}.expire <= $4 OR 1=${forceExpire ? 1 : 0}) THEN $2
ELSE ${this._getTableIdentifier()}.points + ($2)
END,

@@ -291,3 +305,3 @@ expire = ${expireQ}

text: `
SELECT points, expire FROM "${this.tableName}" WHERE key = $1 AND (expire > $2 OR expire IS NULL);`,
SELECT points, expire FROM ${this._getTableIdentifier()} WHERE key = $1 AND (expire > $2 OR expire IS NULL);`,
values: [rlKey, Date.now()],

@@ -314,3 +328,3 @@ })

name: 'rlflx-delete',
text: `DELETE FROM "${this.tableName}" WHERE key = $1`,
text: `DELETE FROM ${this._getTableIdentifier()} WHERE key = $1`,
values: [rlKey],

@@ -317,0 +331,0 @@ })

{
"name": "rate-limiter-flexible",
"version": "3.0.1",
"version": "3.0.2",
"description": "Node.js rate limiter by key and protection from DDoS and Brute-Force attacks in process Memory, Redis, MongoDb, Memcached, MySQL, PostgreSQL, Cluster or PM",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc