Add debug

This commit is contained in:
2022-08-06 20:55:51 +03:00
parent 462032a4e9
commit 376fd7aa35
3 changed files with 20 additions and 1 deletions

View File

@@ -16,6 +16,7 @@
"dependencies": {
"@sentry/node": "^7.8.1",
"chunk-text": "^2.0.1",
"debug": "^4.3.4",
"docker-ip-get": "^1.1.5",
"envalid": "^7.3.1",
"esbuild": "^0.14.53",
@@ -30,6 +31,7 @@
},
"devDependencies": {
"@types/chunk-text": "^1.0.0",
"@types/debug": "^4.1.7",
"@types/express": "^4.17.13",
"@types/node": "^16.11.9",
"@types/safe-compare": "^1.1.0",

View File

@@ -2,10 +2,12 @@ import { createClient, RedisClientType } from 'redis';
import env from '@/config';
import debug from 'debug';
import Sentry from '@/sentry';
export default class Limiter {
static debugger = debug("limiter");
static MAX_PROCESSING_COUNT: number = 3;
static _redisClient: RedisClientType | null = null;
@@ -41,6 +43,9 @@ export default class Limiter {
static async isLimited(updateId: number): Promise<boolean> {
const count = await this._getCount(updateId);
this.debugger(`${updateId}: ${count}`)
return count <= this.MAX_PROCESSING_COUNT;
}
}

View File

@@ -129,6 +129,13 @@
dependencies:
"@types/node" "*"
"@types/debug@^4.1.7":
version "4.1.7"
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.7.tgz#7cc0ea761509124709b8b2d1090d8f6c17aadb82"
integrity sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==
dependencies:
"@types/ms" "*"
"@types/express-serve-static-core@^4.17.18":
version "4.17.28"
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.28.tgz#c47def9f34ec81dc6328d0b1b5303d1ec98d86b8"
@@ -165,6 +172,11 @@
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a"
integrity sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==
"@types/ms@*":
version "0.7.31"
resolved "https://registry.yarnpkg.com/@types/ms/-/ms-0.7.31.tgz#31b7ca6407128a3d2bbc27fe2d21b345397f6197"
integrity sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==
"@types/node@*":
version "17.0.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.21.tgz#864b987c0c68d07b4345845c3e63b75edd143644"
@@ -410,7 +422,7 @@ debug@2.6.9:
dependencies:
ms "2.0.0"
debug@4:
debug@4, debug@^4.3.4:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==