@abyss-project/monitor 1.0.82 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +33 -33
- package/README.md +33 -33
- package/dist/__tests__/rate-limit.decorator.test.js +0 -59
- package/dist/__tests__/rate-limit.decorator.test.js.map +1 -1
- package/dist/__tests__/rate-limit.middleware.test.js +43 -64
- package/dist/__tests__/rate-limit.middleware.test.js.map +1 -1
- package/dist/frameworks/express/index.d.ts +2 -0
- package/dist/frameworks/express/index.js +12 -6
- package/dist/frameworks/express/index.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -6
- package/dist/index.js.map +1 -1
- package/dist/middlewares/rate-limit/index.d.ts +2 -3
- package/dist/middlewares/rate-limit/index.js +2 -4
- package/dist/middlewares/rate-limit/index.js.map +1 -1
- package/dist/middlewares/rate-limit/rate-limit.decorator.d.ts +0 -6
- package/dist/middlewares/rate-limit/rate-limit.decorator.js +1 -44
- package/dist/middlewares/rate-limit/rate-limit.decorator.js.map +1 -1
- package/dist/middlewares/rate-limit/rate-limit.lua.js +72 -72
- package/dist/middlewares/rate-limit/rate-limit.middleware.d.ts +8 -2
- package/dist/middlewares/rate-limit/rate-limit.middleware.js +5 -9
- package/dist/middlewares/rate-limit/rate-limit.middleware.js.map +1 -1
- package/dist/types/interface/api/index.d.ts +1 -0
- package/dist/types/interface/api/index.js +1 -0
- package/dist/types/interface/api/index.js.map +1 -1
- package/dist/types/interface/api/requests/application-log.admin.request.d.ts +2 -2
- package/dist/types/interface/api/requests/application-log.request.d.ts +2 -2
- package/dist/types/interface/api/responses/application-log.admin.response.d.ts +2 -2
- package/dist/types/interface/api/responses/application-log.response.d.ts +2 -2
- package/dist/types/interface/api/type-message/keyset-paginate.d.ts +10 -0
- package/dist/types/interface/api/type-message/keyset-paginate.js +3 -0
- package/dist/types/interface/api/type-message/keyset-paginate.js.map +1 -0
- package/dist/types/interface/rate-limit.d.ts +0 -4
- package/dist/types/interface/rate-limit.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/jest.config.ts +14 -14
- package/package.json +1 -1
- package/tsconfig.json +35 -35
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createRouteRateLimiter } from './rate-limit.middleware';
|
|
2
|
+
export type { RouteRateLimiterContext } from './rate-limit.middleware';
|
|
2
3
|
export { RateLimit, readRateLimitOptions } from './rate-limit.decorator';
|
|
3
|
-
export { buildRateLimitRouteRegistry } from './rate-limit.decorator';
|
|
4
|
-
export type { RateLimitRouteRegistryEntry } from './rate-limit.decorator';
|
|
5
4
|
export { TokenBucketStore } from './token-bucket.store';
|
|
6
5
|
export type { ConsumeArgs, ConsumeDualArgs, SingleResult, DualResult } from './token-bucket.store';
|
|
7
6
|
export { resolveIdentifiers } from './identifier-resolver';
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseWindow = exports.resolveIdentifiers = exports.TokenBucketStore = exports.
|
|
3
|
+
exports.parseWindow = exports.resolveIdentifiers = exports.TokenBucketStore = exports.readRateLimitOptions = exports.RateLimit = exports.createRouteRateLimiter = void 0;
|
|
4
4
|
var rate_limit_middleware_1 = require("./rate-limit.middleware");
|
|
5
|
-
Object.defineProperty(exports, "
|
|
5
|
+
Object.defineProperty(exports, "createRouteRateLimiter", { enumerable: true, get: function () { return rate_limit_middleware_1.createRouteRateLimiter; } });
|
|
6
6
|
var rate_limit_decorator_1 = require("./rate-limit.decorator");
|
|
7
7
|
Object.defineProperty(exports, "RateLimit", { enumerable: true, get: function () { return rate_limit_decorator_1.RateLimit; } });
|
|
8
8
|
Object.defineProperty(exports, "readRateLimitOptions", { enumerable: true, get: function () { return rate_limit_decorator_1.readRateLimitOptions; } });
|
|
9
|
-
var rate_limit_decorator_2 = require("./rate-limit.decorator");
|
|
10
|
-
Object.defineProperty(exports, "buildRateLimitRouteRegistry", { enumerable: true, get: function () { return rate_limit_decorator_2.buildRateLimitRouteRegistry; } });
|
|
11
9
|
var token_bucket_store_1 = require("./token-bucket.store");
|
|
12
10
|
Object.defineProperty(exports, "TokenBucketStore", { enumerable: true, get: function () { return token_bucket_store_1.TokenBucketStore; } });
|
|
13
11
|
var identifier_resolver_1 = require("./identifier-resolver");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/middlewares/rate-limit/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/middlewares/rate-limit/index.ts"],"names":[],"mappings":";;;AAAA,iEAAiE;AAAxD,+HAAA,sBAAsB,OAAA;AAE/B,+DAAyE;AAAhE,iHAAA,SAAS,OAAA;AAAE,4HAAA,oBAAoB,OAAA;AACxC,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AAEzB,6DAA2D;AAAlD,yHAAA,kBAAkB,OAAA;AAE3B,+CAA6C;AAApC,2GAAA,WAAW,OAAA"}
|
|
@@ -3,9 +3,3 @@ import type { RateLimitDecoratorOptions } from '../../types/interface/rate-limit
|
|
|
3
3
|
export declare const RATE_LIMIT_WATERMARK: unique symbol;
|
|
4
4
|
export declare function RateLimit(options: RateLimitDecoratorOptions): MethodDecorator;
|
|
5
5
|
export declare function readRateLimitOptions(target: object, propertyKey: string | symbol): RateLimitDecoratorOptions | undefined;
|
|
6
|
-
export interface RateLimitRouteRegistryEntry {
|
|
7
|
-
method: string;
|
|
8
|
-
path: string;
|
|
9
|
-
options: RateLimitDecoratorOptions;
|
|
10
|
-
}
|
|
11
|
-
export declare function buildRateLimitRouteRegistry(controllers: ReadonlyArray<new (...args: any[]) => unknown>, controllerPrefix: string): RateLimitRouteRegistryEntry[];
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.readRateLimitOptions = exports.RateLimit = exports.RATE_LIMIT_WATERMARK = void 0;
|
|
4
4
|
require("reflect-metadata");
|
|
5
|
-
const metadata_1 = require("../../frameworks/express/metadata");
|
|
6
|
-
const types_1 = require("../../types");
|
|
7
5
|
exports.RATE_LIMIT_WATERMARK = Symbol('abyss:rate-limit');
|
|
8
6
|
function RateLimit(options) {
|
|
9
7
|
return function (target, propertyKey) {
|
|
@@ -15,45 +13,4 @@ function readRateLimitOptions(target, propertyKey) {
|
|
|
15
13
|
return Reflect.getMetadata(exports.RATE_LIMIT_WATERMARK, target, propertyKey);
|
|
16
14
|
}
|
|
17
15
|
exports.readRateLimitOptions = readRateLimitOptions;
|
|
18
|
-
const HTTP_VERB_BY_API_METHOD = {
|
|
19
|
-
[types_1.APIMethod.GET]: 'GET',
|
|
20
|
-
[types_1.APIMethod.POST]: 'POST',
|
|
21
|
-
[types_1.APIMethod.PUT]: 'PUT',
|
|
22
|
-
[types_1.APIMethod.DELETE]: 'DELETE',
|
|
23
|
-
[types_1.APIMethod.PATCH]: 'PATCH',
|
|
24
|
-
};
|
|
25
|
-
function buildRateLimitRouteRegistry(controllers, controllerPrefix) {
|
|
26
|
-
const out = [];
|
|
27
|
-
for (const ControllerClass of controllers) {
|
|
28
|
-
const isController = Reflect.getMetadata(metadata_1.CONTROLLER_WATERMARK, ControllerClass) === true;
|
|
29
|
-
if (!isController)
|
|
30
|
-
continue;
|
|
31
|
-
const controllerBasePath = Reflect.getMetadata(metadata_1.PATH_WATERMARK, ControllerClass) ?? '';
|
|
32
|
-
const proto = ControllerClass.prototype;
|
|
33
|
-
for (const key of Object.getOwnPropertyNames(proto)) {
|
|
34
|
-
if (key === 'constructor')
|
|
35
|
-
continue;
|
|
36
|
-
const isRoute = Reflect.getMetadata(metadata_1.ROUTE_WATERMARK, proto, key) === true;
|
|
37
|
-
if (!isRoute)
|
|
38
|
-
continue;
|
|
39
|
-
const opts = readRateLimitOptions(proto, key);
|
|
40
|
-
if (!opts)
|
|
41
|
-
continue;
|
|
42
|
-
const apiMethod = Reflect.getMetadata(metadata_1.METHOD_WATERMARK, proto, key);
|
|
43
|
-
if (apiMethod === undefined)
|
|
44
|
-
continue;
|
|
45
|
-
const subPath = Reflect.getMetadata(metadata_1.PATH_WATERMARK, proto, key) ?? '';
|
|
46
|
-
const segments = [controllerPrefix, controllerBasePath, subPath]
|
|
47
|
-
.map((part) => part.replace(/^\/+|\/+$/g, ''))
|
|
48
|
-
.filter((part) => part.length > 0);
|
|
49
|
-
out.push({
|
|
50
|
-
method: HTTP_VERB_BY_API_METHOD[apiMethod],
|
|
51
|
-
path: '/' + segments.join('/'),
|
|
52
|
-
options: opts,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return out;
|
|
57
|
-
}
|
|
58
|
-
exports.buildRateLimitRouteRegistry = buildRateLimitRouteRegistry;
|
|
59
16
|
//# sourceMappingURL=rate-limit.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limit.decorator.js","sourceRoot":"","sources":["../../../src/middlewares/rate-limit/rate-limit.decorator.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;
|
|
1
|
+
{"version":3,"file":"rate-limit.decorator.js","sourceRoot":"","sources":["../../../src/middlewares/rate-limit/rate-limit.decorator.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAGb,QAAA,oBAAoB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAE/D,SAAgB,SAAS,CAAC,OAAkC;IAC1D,OAAO,UAAU,MAAM,EAAE,WAAW;QAClC,OAAO,CAAC,cAAc,CAAC,4BAAoB,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAC7E,CAAC,CAAC;AACJ,CAAC;AAJD,8BAIC;AAED,SAAgB,oBAAoB,CAClC,MAAc,EACd,WAA4B;IAE5B,OAAO,OAAO,CAAC,WAAW,CAAC,4BAAoB,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AACxE,CAAC;AALD,oDAKC"}
|
|
@@ -1,77 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RATE_LIMIT_LUA = void 0;
|
|
4
|
-
exports.RATE_LIMIT_LUA = `
|
|
5
|
-
local function load_bucket(key, capacity, refill, now)
|
|
6
|
-
local data = redis.call('HMGET', key, 'tokens', 'ts')
|
|
7
|
-
local tokens = tonumber(data[1])
|
|
8
|
-
local ts = tonumber(data[2])
|
|
9
|
-
if tokens == nil then tokens = capacity end
|
|
10
|
-
if ts == nil then ts = now end
|
|
11
|
-
local elapsed = (now - ts) / 1000.0
|
|
12
|
-
if elapsed < 0 then elapsed = 0 end
|
|
13
|
-
tokens = math.min(capacity, tokens + elapsed * refill)
|
|
14
|
-
return tokens
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
local function save_bucket(key, tokens, capacity, refill, now)
|
|
18
|
-
redis.call('HSET', key, 'tokens', tokens, 'ts', now)
|
|
19
|
-
local ttl = math.ceil(capacity / refill) * 2
|
|
20
|
-
redis.call('EXPIRE', key, ttl)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
local function reset_sec(tokens, capacity, refill, cost)
|
|
24
|
-
if tokens >= cost then return 0 end
|
|
25
|
-
return math.ceil((cost - tokens) / refill)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
local primary_cap = tonumber(ARGV[1])
|
|
29
|
-
local primary_rate = tonumber(ARGV[2])
|
|
30
|
-
local secondary_cap = tonumber(ARGV[3])
|
|
31
|
-
local secondary_rate = tonumber(ARGV[4])
|
|
32
|
-
local now = tonumber(ARGV[5])
|
|
33
|
-
local cost = tonumber(ARGV[6])
|
|
34
|
-
|
|
35
|
-
local primary_tokens = load_bucket(KEYS[1], primary_cap, primary_rate, now)
|
|
36
|
-
local secondary_tokens = 0
|
|
37
|
-
local has_secondary = KEYS[2] ~= nil and KEYS[2] ~= ''
|
|
38
|
-
if has_secondary then
|
|
39
|
-
secondary_tokens = load_bucket(KEYS[2], secondary_cap, secondary_rate, now)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
local allowed = 1
|
|
43
|
-
if primary_tokens < cost then allowed = 0 end
|
|
44
|
-
if has_secondary and secondary_tokens < cost then allowed = 0 end
|
|
45
|
-
|
|
46
|
-
if allowed == 1 then
|
|
47
|
-
primary_tokens = primary_tokens - cost
|
|
48
|
-
save_bucket(KEYS[1], primary_tokens, primary_cap, primary_rate, now)
|
|
49
|
-
if has_secondary then
|
|
50
|
-
secondary_tokens = secondary_tokens - cost
|
|
51
|
-
save_bucket(KEYS[2], secondary_tokens, secondary_cap, secondary_rate, now)
|
|
52
|
-
end
|
|
53
|
-
else
|
|
54
|
-
-- Refresh ts so refill math stays correct on next call without consuming tokens.
|
|
55
|
-
save_bucket(KEYS[1], primary_tokens, primary_cap, primary_rate, now)
|
|
56
|
-
if has_secondary then
|
|
57
|
-
save_bucket(KEYS[2], secondary_tokens, secondary_cap, secondary_rate, now)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
local primary_reset = reset_sec(primary_tokens, primary_cap, primary_rate, cost)
|
|
62
|
-
local secondary_reset = 0
|
|
63
|
-
if has_secondary then
|
|
64
|
-
secondary_reset = reset_sec(secondary_tokens, secondary_cap, secondary_rate, cost)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
allowed,
|
|
69
|
-
math.floor(primary_tokens),
|
|
70
|
-
primary_cap,
|
|
71
|
-
primary_reset,
|
|
72
|
-
math.floor(secondary_tokens),
|
|
73
|
-
secondary_cap,
|
|
74
|
-
secondary_reset,
|
|
75
|
-
}
|
|
4
|
+
exports.RATE_LIMIT_LUA = `
|
|
5
|
+
local function load_bucket(key, capacity, refill, now)
|
|
6
|
+
local data = redis.call('HMGET', key, 'tokens', 'ts')
|
|
7
|
+
local tokens = tonumber(data[1])
|
|
8
|
+
local ts = tonumber(data[2])
|
|
9
|
+
if tokens == nil then tokens = capacity end
|
|
10
|
+
if ts == nil then ts = now end
|
|
11
|
+
local elapsed = (now - ts) / 1000.0
|
|
12
|
+
if elapsed < 0 then elapsed = 0 end
|
|
13
|
+
tokens = math.min(capacity, tokens + elapsed * refill)
|
|
14
|
+
return tokens
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
local function save_bucket(key, tokens, capacity, refill, now)
|
|
18
|
+
redis.call('HSET', key, 'tokens', tokens, 'ts', now)
|
|
19
|
+
local ttl = math.ceil(capacity / refill) * 2
|
|
20
|
+
redis.call('EXPIRE', key, ttl)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
local function reset_sec(tokens, capacity, refill, cost)
|
|
24
|
+
if tokens >= cost then return 0 end
|
|
25
|
+
return math.ceil((cost - tokens) / refill)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
local primary_cap = tonumber(ARGV[1])
|
|
29
|
+
local primary_rate = tonumber(ARGV[2])
|
|
30
|
+
local secondary_cap = tonumber(ARGV[3])
|
|
31
|
+
local secondary_rate = tonumber(ARGV[4])
|
|
32
|
+
local now = tonumber(ARGV[5])
|
|
33
|
+
local cost = tonumber(ARGV[6])
|
|
34
|
+
|
|
35
|
+
local primary_tokens = load_bucket(KEYS[1], primary_cap, primary_rate, now)
|
|
36
|
+
local secondary_tokens = 0
|
|
37
|
+
local has_secondary = KEYS[2] ~= nil and KEYS[2] ~= ''
|
|
38
|
+
if has_secondary then
|
|
39
|
+
secondary_tokens = load_bucket(KEYS[2], secondary_cap, secondary_rate, now)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
local allowed = 1
|
|
43
|
+
if primary_tokens < cost then allowed = 0 end
|
|
44
|
+
if has_secondary and secondary_tokens < cost then allowed = 0 end
|
|
45
|
+
|
|
46
|
+
if allowed == 1 then
|
|
47
|
+
primary_tokens = primary_tokens - cost
|
|
48
|
+
save_bucket(KEYS[1], primary_tokens, primary_cap, primary_rate, now)
|
|
49
|
+
if has_secondary then
|
|
50
|
+
secondary_tokens = secondary_tokens - cost
|
|
51
|
+
save_bucket(KEYS[2], secondary_tokens, secondary_cap, secondary_rate, now)
|
|
52
|
+
end
|
|
53
|
+
else
|
|
54
|
+
-- Refresh ts so refill math stays correct on next call without consuming tokens.
|
|
55
|
+
save_bucket(KEYS[1], primary_tokens, primary_cap, primary_rate, now)
|
|
56
|
+
if has_secondary then
|
|
57
|
+
save_bucket(KEYS[2], secondary_tokens, secondary_cap, secondary_rate, now)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
local primary_reset = reset_sec(primary_tokens, primary_cap, primary_rate, cost)
|
|
62
|
+
local secondary_reset = 0
|
|
63
|
+
if has_secondary then
|
|
64
|
+
secondary_reset = reset_sec(secondary_tokens, secondary_cap, secondary_rate, cost)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
allowed,
|
|
69
|
+
math.floor(primary_tokens),
|
|
70
|
+
primary_cap,
|
|
71
|
+
primary_reset,
|
|
72
|
+
math.floor(secondary_tokens),
|
|
73
|
+
secondary_cap,
|
|
74
|
+
secondary_reset,
|
|
75
|
+
}
|
|
76
76
|
`;
|
|
77
77
|
//# sourceMappingURL=rate-limit.lua.js.map
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { Request, Response, NextFunction } from 'express-serve-static-core';
|
|
2
2
|
import type { TokenBucketStore } from './token-bucket.store';
|
|
3
|
-
import type { RateLimitMiddlewareOptions } from '../../types/interface/rate-limit';
|
|
4
|
-
export
|
|
3
|
+
import type { RateLimitConfig, RateLimitDecoratorOptions, RateLimitMiddlewareOptions } from '../../types/interface/rate-limit';
|
|
4
|
+
export interface RouteRateLimiterContext {
|
|
5
|
+
store: TokenBucketStore;
|
|
6
|
+
config: RateLimitConfig;
|
|
7
|
+
logger?: RateLimitMiddlewareOptions['logger'];
|
|
8
|
+
onExceeded?: RateLimitMiddlewareOptions['onExceeded'];
|
|
9
|
+
}
|
|
10
|
+
export declare function createRouteRateLimiter(routeOptions: RateLimitDecoratorOptions | undefined, ctx: RouteRateLimiterContext): (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createRouteRateLimiter = void 0;
|
|
4
4
|
const identifier_resolver_1 = require("./identifier-resolver");
|
|
5
5
|
const parse_window_1 = require("./parse-window");
|
|
6
6
|
function buildKey(prefix, scope, id) {
|
|
@@ -75,12 +75,8 @@ function setSuccessHeaders(res, bucket, remaining, resetSec) {
|
|
|
75
75
|
res.setHeader('RateLimit-Reset', resetSec);
|
|
76
76
|
res.setHeader('RateLimit-Policy', `${bucket.max};w=${bucket.windowSec}`);
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
const { config, logger, onExceeded } =
|
|
80
|
-
const routeOverrideLookup = new Map();
|
|
81
|
-
for (const entry of options.routeRegistry ?? []) {
|
|
82
|
-
routeOverrideLookup.set(`${entry.method}:${entry.path}`, entry.options);
|
|
83
|
-
}
|
|
78
|
+
function createRouteRateLimiter(routeOptions, ctx) {
|
|
79
|
+
const { store, config, logger, onExceeded } = ctx;
|
|
84
80
|
return async function rateLimitMiddleware(req, res, next) {
|
|
85
81
|
if (!config.enabled) {
|
|
86
82
|
next();
|
|
@@ -91,7 +87,7 @@ function createRateLimitMiddleware(options, store) {
|
|
|
91
87
|
next();
|
|
92
88
|
return;
|
|
93
89
|
}
|
|
94
|
-
const override =
|
|
90
|
+
const override = routeOptions;
|
|
95
91
|
const cost = override?.cost ?? 1;
|
|
96
92
|
let effectiveIdentifier = identifier;
|
|
97
93
|
if (override?.scope === 'ip') {
|
|
@@ -145,7 +141,7 @@ function createRateLimitMiddleware(options, store) {
|
|
|
145
141
|
next();
|
|
146
142
|
};
|
|
147
143
|
}
|
|
148
|
-
exports.
|
|
144
|
+
exports.createRouteRateLimiter = createRouteRateLimiter;
|
|
149
145
|
function respond429(res, bucket, resetSec) {
|
|
150
146
|
res.setHeader('RateLimit-Limit', bucket.max);
|
|
151
147
|
res.setHeader('RateLimit-Remaining', 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limit.middleware.js","sourceRoot":"","sources":["../../../src/middlewares/rate-limit/rate-limit.middleware.ts"],"names":[],"mappings":";;;AAGA,+DAA2D;AAC3D,iDAA6C;AAgB7C,SAAS,QAAQ,CAAC,MAAc,EAAE,KAAqB,EAAE,EAAU;IACjE,OAAO,MAAM,MAAM,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;AACvC,CAAC;AAED,SAAS,aAAa,CACpB,IAAqC,EACrC,QAA+C;IAE/C,OAAO;QACL,GAAG,EAAE,QAAQ,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG;QAC9B,SAAS,EAAE,IAAA,0BAAW,EAAE,QAAQ,EAAE,MAAiB,IAAI,IAAI,CAAC,MAAM,CAAC;KACpE,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CACnB,UAA8B,EAC9B,MAAuB,EACvB,QAA+C;IAE/C,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,OAAO;YACV,OAAO,EAAE,CAAC;QACZ,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACnD,OAAO;gBACL,OAAO,EAAE;oBACP,KAAK,EAAE,QAAQ;oBACf,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC;oBAChE,GAAG,EAAE,GAAG,CAAC,GAAG;oBACZ,SAAS,EAAE,GAAG,CAAC,SAAS;iBACzB;aACF,CAA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,CAAC,GAAG;YACjB,MAAM,EAAE,MAAM,CAAC,SAAS;YACxB,UAAU,EAAE,QAAQ;SACrB;KACF,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,YAAY,CACzB,GAAY,EACZ,MAAsB,EACtB,QAAgB,EAChB,MAA6C,EAC7C,UAAqD;IAErD,MAAM,IAAI,GAA0B;QAClC,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,UAAU,EAAE,MAAM,CAAC,GAAG;QACtB,KAAK,EAAE,MAAM,CAAC,GAAG;QACjB,aAAa,EAAE,MAAM,CAAC,SAAS;QAC/B,iBAAiB,EAAE,QAAQ;QAC3B,QAAQ,EAAE,GAAG,CAAC,IAAI;QAClB,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE;KACjB,CAAC;IACF,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAChD,MAAM,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE;YACvC,OAAO,EAAE,YAAY;YACrB,IAAI,EAAE,IAA0C;SACjD,CAAC,CAAC;IACL,CAAC;IACD,IAAI,UAAU;QAAE,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -2,6 +2,7 @@ export * from './type-message/api-error';
|
|
|
2
2
|
export * from './type-message/response';
|
|
3
3
|
export * from './type-message/base-order';
|
|
4
4
|
export * from './type-message/base-paginate';
|
|
5
|
+
export * from './type-message/keyset-paginate';
|
|
5
6
|
export * from './requests/application.request';
|
|
6
7
|
export * from './requests/application.admin.request';
|
|
7
8
|
export * from './requests/application-stats.admin.request';
|
|
@@ -18,6 +18,7 @@ __exportStar(require("./type-message/api-error"), exports);
|
|
|
18
18
|
__exportStar(require("./type-message/response"), exports);
|
|
19
19
|
__exportStar(require("./type-message/base-order"), exports);
|
|
20
20
|
__exportStar(require("./type-message/base-paginate"), exports);
|
|
21
|
+
__exportStar(require("./type-message/keyset-paginate"), exports);
|
|
21
22
|
__exportStar(require("./requests/application.request"), exports);
|
|
22
23
|
__exportStar(require("./requests/application.admin.request"), exports);
|
|
23
24
|
__exportStar(require("./requests/application-stats.admin.request"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/interface/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,0DAAwC;AACxC,4DAA0C;AAC1C,+DAA6C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/interface/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,0DAAwC;AACxC,4DAA0C;AAC1C,+DAA6C;AAC7C,iEAA+C;AAE/C,iEAA+C;AAC/C,uEAAqD;AACrD,6EAA2D;AAC3D,uEAAqD;AACrD,iFAA+D;AAC/D,2EAAyD;AACzD,2EAAyD;AACzD,qEAAmD;AACnD,uEAAqD;AACrD,6EAA2D;AAC3D,yEAAuD;AACvD,+EAA6D;AAC7D,uFAAqE;AACrE,iFAA+D;AAC/D,gFAA8D;AAC9D,0EAAwD;AACxD,6DAA2C;AAC3C,mEAAiD;AACjD,oEAAkD;AAClD,kEAAgD;AAChD,0EAAwD;AAExD,mEAAiD;AACjD,yEAAuD;AACvD,+EAA6D;AAC7D,yEAAuD;AACvD,mFAAiE;AACjE,6EAA2D;AAC3D,6EAA2D;AAC3D,uEAAqD;AACrD,+DAA6C;AAC7C,yEAAuD;AACvD,+EAA6D;AAC7D,2EAAyD;AACzD,iFAA+D;AAC/D,yFAAuE;AACvE,mFAAiE;AACjE,kFAAgE;AAChE,4EAA0D;AAC1D,+DAA6C;AAC7C,qEAAmD;AACnD,sEAAoD;AACpD,oEAAkD;AAClD,4EAA0D"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CursorQuery } from '..';
|
|
2
2
|
import { LogLevel } from '../../../enum';
|
|
3
3
|
export interface IGetApplicationLogAdminParams {
|
|
4
4
|
applicationLogId: string;
|
|
5
5
|
}
|
|
6
|
-
export type IPaginateApplicationLogAdminQuery =
|
|
6
|
+
export type IPaginateApplicationLogAdminQuery = CursorQuery & {
|
|
7
7
|
title?: string;
|
|
8
8
|
message?: string;
|
|
9
9
|
level?: LogLevel[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CursorQuery } from '..';
|
|
2
2
|
import { APIMethod, LogLevel } from '../../../enum';
|
|
3
3
|
export interface IGetApplicationLogParams {
|
|
4
4
|
applicationId: string;
|
|
@@ -7,7 +7,7 @@ export interface IGetApplicationLogParams {
|
|
|
7
7
|
export interface IPaginateApplicationLogParams {
|
|
8
8
|
applicationId: string;
|
|
9
9
|
}
|
|
10
|
-
export type IPaginateApplicationLogQuery =
|
|
10
|
+
export type IPaginateApplicationLogQuery = CursorQuery & {
|
|
11
11
|
title?: string;
|
|
12
12
|
message?: string;
|
|
13
13
|
level?: LogLevel[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IResponse, IApplicationLog,
|
|
2
|
-
export type IPaginateApplicationLogAdminResponse = IResponse<
|
|
1
|
+
import { IResponse, IApplicationLog, KeysetPaginate } from '../..';
|
|
2
|
+
export type IPaginateApplicationLogAdminResponse = IResponse<KeysetPaginate<IApplicationLog>>;
|
|
3
3
|
export interface IGetApplicationLogAdminData {
|
|
4
4
|
applicationLog: IApplicationLog;
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IResponse, IApplicationLog,
|
|
2
|
-
export type IPaginateApplicationLogResponse = IResponse<
|
|
1
|
+
import { IResponse, IApplicationLog, KeysetPaginate } from '../..';
|
|
2
|
+
export type IPaginateApplicationLogResponse = IResponse<KeysetPaginate<IApplicationLog>>;
|
|
3
3
|
export interface IGetApplicationLogData {
|
|
4
4
|
applicationLog: IApplicationLog;
|
|
5
5
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyset-paginate.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/type-message/keyset-paginate.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { Redis } from 'ioredis';
|
|
2
1
|
import type { Logger } from '../../models';
|
|
3
2
|
import type { RateLimitWindow } from '../../middlewares/rate-limit/parse-window';
|
|
4
|
-
import type { RateLimitRouteRegistryEntry } from '../../middlewares/rate-limit/rate-limit.decorator';
|
|
5
3
|
export type RateLimitScope = 'admin' | 'apikey' | 'user' | 'org' | 'ip';
|
|
6
4
|
export interface RateLimitBucketConfig {
|
|
7
5
|
max: number;
|
|
@@ -22,10 +20,8 @@ export interface RateLimitDecoratorOptions {
|
|
|
22
20
|
cost?: number;
|
|
23
21
|
}
|
|
24
22
|
export interface RateLimitMiddlewareOptions {
|
|
25
|
-
redis: Redis;
|
|
26
23
|
config: RateLimitConfig;
|
|
27
24
|
logger?: Logger;
|
|
28
|
-
routeRegistry?: RateLimitRouteRegistryEntry[];
|
|
29
25
|
onExceeded?: (info: RateLimitExceededInfo) => Promise<void> | void;
|
|
30
26
|
}
|
|
31
27
|
export interface RateLimitExceededInfo {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limit.js","sourceRoot":"","sources":["../../../src/types/interface/rate-limit.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"rate-limit.js","sourceRoot":"","sources":["../../../src/types/interface/rate-limit.ts"],"names":[],"mappings":";;;AAkDa,QAAA,mBAAmB,GAAqD;IACnF,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;IAChC,GAAG,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAChC,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;IAClC,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;CAC9B,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./error.utils"), exports);
|
|
18
|
+
__exportStar(require("./billing-quota-error.utils"), exports);
|
|
18
19
|
__exportStar(require("./discord-webhook-log-formatter.utils"), exports);
|
|
19
20
|
__exportStar(require("./json.utils"), exports);
|
|
20
21
|
__exportStar(require("./alert.utils"), exports);
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,8DAA4C;AAC5C,wEAAsD;AACtD,+CAA6B;AAC7B,gDAA8B;AAC9B,+DAA6C;AAC7C,0DAAwC;AACxC,4DAA0C;AAC1C,iDAA+B;AAC/B,mDAAiC;AACjC,iDAA+B"}
|
package/jest.config.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { Config } from '@jest/types';
|
|
2
|
-
|
|
3
|
-
const config: Config.InitialOptions = {
|
|
4
|
-
testEnvironment: 'node',
|
|
5
|
-
testTimeout: 10000,
|
|
6
|
-
verbose: true,
|
|
7
|
-
transform: {
|
|
8
|
-
'^.+\\.tsx?$': ['ts-jest', { isolatedModules: true }],
|
|
9
|
-
},
|
|
10
|
-
testMatch: ['<rootDir>/src/**/__tests__/**/*.test.ts'],
|
|
11
|
-
modulePathIgnorePatterns: ['dist'],
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export default config;
|
|
1
|
+
import type { Config } from '@jest/types';
|
|
2
|
+
|
|
3
|
+
const config: Config.InitialOptions = {
|
|
4
|
+
testEnvironment: 'node',
|
|
5
|
+
testTimeout: 10000,
|
|
6
|
+
verbose: true,
|
|
7
|
+
transform: {
|
|
8
|
+
'^.+\\.tsx?$': ['ts-jest', { isolatedModules: true }],
|
|
9
|
+
},
|
|
10
|
+
testMatch: ['<rootDir>/src/**/__tests__/**/*.test.ts'],
|
|
11
|
+
modulePathIgnorePatterns: ['dist'],
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default config;
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"incremental": false,
|
|
4
|
-
"target": "es2021",
|
|
5
|
-
"lib": [
|
|
6
|
-
"dom",
|
|
7
|
-
"es2021"
|
|
8
|
-
],
|
|
9
|
-
"experimentalDecorators": true,
|
|
10
|
-
"emitDecoratorMetadata": true,
|
|
11
|
-
"module": "commonjs",
|
|
12
|
-
"rootDir": "src",
|
|
13
|
-
"moduleResolution": "node",
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
"allowJs": true,
|
|
16
|
-
"declaration": true,
|
|
17
|
-
"sourceMap": true,
|
|
18
|
-
"outDir": "./dist",
|
|
19
|
-
"removeComments": true,
|
|
20
|
-
"allowSyntheticDefaultImports": true,
|
|
21
|
-
"esModuleInterop": true,
|
|
22
|
-
"forceConsistentCasingInFileNames": true,
|
|
23
|
-
"strict": true,
|
|
24
|
-
"strictNullChecks": true,
|
|
25
|
-
"strictFunctionTypes": true,
|
|
26
|
-
"strictPropertyInitialization": false,
|
|
27
|
-
"skipLibCheck": true
|
|
28
|
-
},
|
|
29
|
-
"include": [
|
|
30
|
-
"./src"
|
|
31
|
-
],
|
|
32
|
-
"exclude": [
|
|
33
|
-
"./dist/**/*"
|
|
34
|
-
]
|
|
35
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"incremental": false,
|
|
4
|
+
"target": "es2021",
|
|
5
|
+
"lib": [
|
|
6
|
+
"dom",
|
|
7
|
+
"es2021"
|
|
8
|
+
],
|
|
9
|
+
"experimentalDecorators": true,
|
|
10
|
+
"emitDecoratorMetadata": true,
|
|
11
|
+
"module": "commonjs",
|
|
12
|
+
"rootDir": "src",
|
|
13
|
+
"moduleResolution": "node",
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"allowJs": true,
|
|
16
|
+
"declaration": true,
|
|
17
|
+
"sourceMap": true,
|
|
18
|
+
"outDir": "./dist",
|
|
19
|
+
"removeComments": true,
|
|
20
|
+
"allowSyntheticDefaultImports": true,
|
|
21
|
+
"esModuleInterop": true,
|
|
22
|
+
"forceConsistentCasingInFileNames": true,
|
|
23
|
+
"strict": true,
|
|
24
|
+
"strictNullChecks": true,
|
|
25
|
+
"strictFunctionTypes": true,
|
|
26
|
+
"strictPropertyInitialization": false,
|
|
27
|
+
"skipLibCheck": true
|
|
28
|
+
},
|
|
29
|
+
"include": [
|
|
30
|
+
"./src"
|
|
31
|
+
],
|
|
32
|
+
"exclude": [
|
|
33
|
+
"./dist/**/*"
|
|
34
|
+
]
|
|
35
|
+
}
|