@carlonicora/nestjs-neo4jsonapi 1.106.0 → 1.107.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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ExecutionContext } from "@nestjs/common";
|
|
1
2
|
import { ThrottlerGuard, ThrottlerRequest } from "@nestjs/throttler";
|
|
2
3
|
import { FastifyRequest } from "fastify";
|
|
3
4
|
/**
|
|
@@ -13,6 +14,18 @@ import { FastifyRequest } from "fastify";
|
|
|
13
14
|
*/
|
|
14
15
|
export declare class CustomThrottlerGuard extends ThrottlerGuard {
|
|
15
16
|
protected getTracker(req: FastifyRequest): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Skip throttling for non-HTTP execution contexts.
|
|
19
|
+
*
|
|
20
|
+
* This guard is registered globally (APP_GUARD), so NestJS also runs it on
|
|
21
|
+
* non-HTTP contexts such as necord Discord slash commands (context type
|
|
22
|
+
* "necord"). Those contexts have no HTTP response object, so calling
|
|
23
|
+
* `switchToHttp().getResponse().header(...)` in `handleRequest` throws
|
|
24
|
+
* `TypeError: response.header is not a function` and, inside a Discord event
|
|
25
|
+
* handler, crashes the worker with an unhandled 'error'. Rate-limit headers
|
|
26
|
+
* only make sense for HTTP, so we skip everything else.
|
|
27
|
+
*/
|
|
28
|
+
protected shouldSkip(context: ExecutionContext): Promise<boolean>;
|
|
16
29
|
protected handleRequest(requestProps: ThrottlerRequest): Promise<boolean>;
|
|
17
30
|
}
|
|
18
31
|
//# sourceMappingURL=custom-throttler.guard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-throttler.guard.d.ts","sourceRoot":"","sources":["../../../src/common/guards/custom-throttler.guard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"custom-throttler.guard.d.ts","sourceRoot":"","sources":["../../../src/common/guards/custom-throttler.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAc,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAgB,cAAc,EAAE,MAAM,SAAS,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,qBACa,oBAAqB,SAAQ,cAAc;cACtC,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAIhE;;;;;;;;;;OAUG;cACa,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;cAIvD,aAAa,CAAC,YAAY,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;CAyChF"}
|
|
@@ -24,6 +24,20 @@ let CustomThrottlerGuard = class CustomThrottlerGuard extends throttler_1.Thrott
|
|
|
24
24
|
async getTracker(req) {
|
|
25
25
|
return req.ip;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Skip throttling for non-HTTP execution contexts.
|
|
29
|
+
*
|
|
30
|
+
* This guard is registered globally (APP_GUARD), so NestJS also runs it on
|
|
31
|
+
* non-HTTP contexts such as necord Discord slash commands (context type
|
|
32
|
+
* "necord"). Those contexts have no HTTP response object, so calling
|
|
33
|
+
* `switchToHttp().getResponse().header(...)` in `handleRequest` throws
|
|
34
|
+
* `TypeError: response.header is not a function` and, inside a Discord event
|
|
35
|
+
* handler, crashes the worker with an unhandled 'error'. Rate-limit headers
|
|
36
|
+
* only make sense for HTTP, so we skip everything else.
|
|
37
|
+
*/
|
|
38
|
+
async shouldSkip(context) {
|
|
39
|
+
return context.getType() !== "http";
|
|
40
|
+
}
|
|
27
41
|
async handleRequest(requestProps) {
|
|
28
42
|
const { context, limit, ttl, throttler, blockDuration, getTracker, generateKey } = requestProps;
|
|
29
43
|
const response = context.switchToHttp().getResponse();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-throttler.guard.js","sourceRoot":"","sources":["../../../src/common/guards/custom-throttler.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"custom-throttler.guard.js","sourceRoot":"","sources":["../../../src/common/guards/custom-throttler.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA8D;AAC9D,iDAAqE;AAGrE;;;;;;;;;;GAUG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,0BAAc;IAC5C,KAAK,CAAC,UAAU,CAAC,GAAmB;QAC5C,OAAO,GAAG,CAAC,EAAE,CAAC;IAChB,CAAC;IAED;;;;;;;;;;OAUG;IACO,KAAK,CAAC,UAAU,CAAC,OAAyB;QAClD,OAAO,OAAO,CAAC,OAAO,EAAE,KAAK,MAAM,CAAC;IACtC,CAAC;IAES,KAAK,CAAC,aAAa,CAAC,YAA8B;QAC1D,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,YAAY,CAAC;QAEhG,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,WAAW,EAAgB,CAAC;QACpE,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAkB,CAAC;QAEpE,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACnD,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC;QAClD,MAAM,GAAG,GAAG,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;QAEzD,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CACrE,GAAG,EACH,GAAG,EACH,KAAK,EACL,aAAa,EACb,aAAa,CACd,CAAC;QAEF,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC,CAAC;QACjD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;QAEhF,2CAA2C;QAC3C,QAAQ,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACpD,QAAQ,CAAC,MAAM,CAAC,uBAAuB,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;QAC5D,QAAQ,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;QAExD,IAAI,SAAS,GAAG,KAAK,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE;gBAC3C,SAAS;gBACT,YAAY;gBACZ,SAAS,EAAE,SAAS,GAAG,KAAK;gBAC5B,iBAAiB,EAAE,YAAY;gBAC/B,GAAG;gBACH,KAAK;gBACL,GAAG;gBACH,OAAO;aACR,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AA7DY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;GACA,oBAAoB,CA6DhC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carlonicora/nestjs-neo4jsonapi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.107.0",
|
|
4
4
|
"description": "NestJS foundation package with JSON:API, Neo4j, Redis, LangChain agents, and common utilities",
|
|
5
5
|
"author": "Carlo Nicora",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|