rate-limiter-flexible
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -55,3 +55,3 @@ const RateLimiterStoreAbstract = require('./RateLimiterStoreAbstract'); | ||
.then((conn) => { | ||
conn.query(`DELETE FROM ${this.tableName} WHERE expire < ?`, [expire], () => { | ||
conn.query(`DELETE FROM ??.?? WHERE expire < ?`, [this.dbName, this.tableName, expire], () => { | ||
this._releaseConnection(conn); | ||
@@ -128,3 +128,3 @@ resolve(); | ||
.then((conn) => { | ||
conn.query(`CREATE DATABASE IF NOT EXISTS ${this.dbName};`, (errDb) => { | ||
conn.query(`CREATE DATABASE IF NOT EXISTS \`${this.dbName}\`;`, (errDb) => { | ||
if (errDb) { | ||
@@ -151,3 +151,3 @@ this._releaseConnection(conn); | ||
_getCreateTableStmt() { | ||
return `CREATE TABLE IF NOT EXISTS ${this.tableName} (` + | ||
return `CREATE TABLE IF NOT EXISTS \`${this.dbName}\`.\`${this.tableName}\` (` + | ||
'`key` VARCHAR(255) CHARACTER SET utf8 NOT NULL,' + | ||
@@ -192,3 +192,3 @@ '`points` INT(9) NOT NULL default 0,' + | ||
set tableName(value) { | ||
this._tableName = typeof value === 'undefined' ? `${this.dbName}.${this.keyPrefix}` : `${this.dbName}.${value}`; | ||
this._tableName = typeof value === 'undefined' ? this.keyPrefix : value; | ||
} | ||
@@ -232,3 +232,3 @@ | ||
if (forceExpire) { | ||
q = `INSERT INTO ?? VALUES (?, ?, ?) | ||
q = `INSERT INTO ??.?? VALUES (?, ?, ?) | ||
ON DUPLICATE KEY UPDATE | ||
@@ -238,3 +238,3 @@ points = ?, | ||
values = [ | ||
this.tableName, key, points, newExpire, | ||
this.dbName, this.tableName, key, points, newExpire, | ||
points, | ||
@@ -244,3 +244,3 @@ newExpire, | ||
} else { | ||
q = `INSERT INTO ?? VALUES (?, ?, ?) | ||
q = `INSERT INTO ??.?? VALUES (?, ?, ?) | ||
ON DUPLICATE KEY UPDATE | ||
@@ -250,3 +250,3 @@ points = IF(expire <= ?, ?, points + (?)), | ||
values = [ | ||
this.tableName, key, points, newExpire, | ||
this.dbName, this.tableName, key, points, newExpire, | ||
dateNow, points, points, | ||
@@ -263,3 +263,3 @@ dateNow, newExpire, | ||
} | ||
conn.query('SELECT points, expire FROM ?? WHERE `key` = ?;', [this.tableName, key], (errSelect, res) => { | ||
conn.query('SELECT points, expire FROM ??.?? WHERE `key` = ?;', [this.dbName, this.tableName, key], (errSelect, res) => { | ||
if (errSelect) { | ||
@@ -319,4 +319,4 @@ conn.rollback(); | ||
conn.query( | ||
'SELECT points, expire FROM ?? WHERE `key` = ? AND `expire` > ?', | ||
[this.tableName, rlKey, Date.now()], | ||
'SELECT points, expire FROM ??.?? WHERE `key` = ? AND `expire` > ?', | ||
[this.dbName, this.tableName, rlKey, Date.now()], | ||
(err, res) => { | ||
@@ -350,4 +350,4 @@ if (err) { | ||
conn.query( | ||
'DELETE FROM ?? WHERE `key` = ?', | ||
[this.tableName, rlKey], | ||
'DELETE FROM ??.?? WHERE `key` = ?', | ||
[this.dbName, this.tableName, rlKey], | ||
(err, res) => { | ||
@@ -354,0 +354,0 @@ if (err) { |
{ | ||
"name": "rate-limiter-flexible", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100140