@pristine-ts/networking 0.0.327 → 0.0.329
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/dist/lib/cjs/cache/cached.router-route.js +27 -5
- package/dist/lib/cjs/cache/cached.router-route.js.map +1 -1
- package/dist/lib/esm/cache/cached.router-route.js +27 -5
- package/dist/lib/esm/cache/cached.router-route.js.map +1 -1
- package/dist/types/cache/cached.router-route.d.ts +1 -1
- package/package.json +7 -7
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CachedRouterRoute = void 0;
|
|
4
|
-
const
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const url_1 = require("url");
|
|
5
6
|
class CachedRouterRoute {
|
|
6
7
|
constructor(methodNode) {
|
|
7
8
|
this.methodNode = methodNode;
|
|
8
9
|
this.cachedControllerMethodArguments = {};
|
|
9
10
|
}
|
|
10
|
-
hashRequest(request) {
|
|
11
|
-
|
|
11
|
+
static hashRequest(request) {
|
|
12
|
+
const sort = (obj) => {
|
|
13
|
+
const ret = {};
|
|
14
|
+
Object.keys(obj).sort().forEach(function (key) {
|
|
15
|
+
ret[key] = obj[key];
|
|
16
|
+
});
|
|
17
|
+
return ret;
|
|
18
|
+
};
|
|
19
|
+
const hash = (0, crypto_1.createHash)("md5");
|
|
20
|
+
const parsedUrl = new url_1.URL(request.url);
|
|
21
|
+
parsedUrl.searchParams.sort();
|
|
22
|
+
hash.update(parsedUrl.pathname);
|
|
23
|
+
hash.update(request.httpMethod);
|
|
24
|
+
hash.update(parsedUrl.searchParams.toString());
|
|
25
|
+
hash.update(parsedUrl.hash);
|
|
26
|
+
hash.update(JSON.stringify(sort(request.headers)));
|
|
27
|
+
try {
|
|
28
|
+
hash.write(JSON.stringify(request.body));
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return hash.digest("hex");
|
|
12
34
|
}
|
|
13
35
|
getCachedControllerMethodArguments(request) {
|
|
14
36
|
// Hashed the request
|
|
15
|
-
const hash =
|
|
37
|
+
const hash = CachedRouterRoute.hashRequest(request);
|
|
16
38
|
if (hash === null) {
|
|
17
39
|
return;
|
|
18
40
|
}
|
|
@@ -21,7 +43,7 @@ class CachedRouterRoute {
|
|
|
21
43
|
}
|
|
22
44
|
cacheControllerMethodArguments(request, methodArguments) {
|
|
23
45
|
// Hashed the request
|
|
24
|
-
const hash =
|
|
46
|
+
const hash = CachedRouterRoute.hashRequest(request);
|
|
25
47
|
if (hash === null) {
|
|
26
48
|
return;
|
|
27
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cached.router-route.js","sourceRoot":"","sources":["../../../../src/cache/cached.router-route.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"cached.router-route.js","sourceRoot":"","sources":["../../../../src/cache/cached.router-route.ts"],"names":[],"mappings":";;;AAEA,mCAAkC;AAClC,6BAAwB;AAExB,MAAa,iBAAiB;IAI1B,YAA4B,UAA4B;QAA5B,eAAU,GAAV,UAAU,CAAkB;QAHhD,oCAA+B,GAAqC,EAAE,CAAC;IAK/E,CAAC;IAEM,MAAM,CAAC,WAAW,CAAC,OAAgB;QACtC,MAAM,IAAI,GAAG,CAAC,GAAQ,EAAE,EAAE;YACtB,MAAM,GAAG,GAAQ,EAAE,CAAC;YAEpB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,UAAU,GAAG;gBACzC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC;YAEH,OAAO,GAAG,CAAC;QACf,CAAC,CAAC;QAEF,MAAM,IAAI,GAAG,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAC;QAE/B,MAAM,SAAS,GAAG,IAAI,S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,CAAC;IACjE,CAAC;CACJ;AAhED,8CAgEC"}
|
|
@@ -1,15 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash } from "crypto";
|
|
2
|
+
import { URL } from "url";
|
|
2
3
|
export class CachedRouterRoute {
|
|
3
4
|
constructor(methodNode) {
|
|
4
5
|
this.methodNode = methodNode;
|
|
5
6
|
this.cachedControllerMethodArguments = {};
|
|
6
7
|
}
|
|
7
|
-
hashRequest(request) {
|
|
8
|
-
|
|
8
|
+
static hashRequest(request) {
|
|
9
|
+
const sort = (obj) => {
|
|
10
|
+
const ret = {};
|
|
11
|
+
Object.keys(obj).sort().forEach(function (key) {
|
|
12
|
+
ret[key] = obj[key];
|
|
13
|
+
});
|
|
14
|
+
return ret;
|
|
15
|
+
};
|
|
16
|
+
const hash = createHash("md5");
|
|
17
|
+
const parsedUrl = new URL(request.url);
|
|
18
|
+
parsedUrl.searchParams.sort();
|
|
19
|
+
hash.update(parsedUrl.pathname);
|
|
20
|
+
hash.update(request.httpMethod);
|
|
21
|
+
hash.update(parsedUrl.searchParams.toString());
|
|
22
|
+
hash.update(parsedUrl.hash);
|
|
23
|
+
hash.update(JSON.stringify(sort(request.headers)));
|
|
24
|
+
try {
|
|
25
|
+
hash.write(JSON.stringify(request.body));
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return hash.digest("hex");
|
|
9
31
|
}
|
|
10
32
|
getCachedControllerMethodArguments(request) {
|
|
11
33
|
// Hashed the request
|
|
12
|
-
const hash =
|
|
34
|
+
const hash = CachedRouterRoute.hashRequest(request);
|
|
13
35
|
if (hash === null) {
|
|
14
36
|
return;
|
|
15
37
|
}
|
|
@@ -18,7 +40,7 @@ export class CachedRouterRoute {
|
|
|
18
40
|
}
|
|
19
41
|
cacheControllerMethodArguments(request, methodArguments) {
|
|
20
42
|
// Hashed the request
|
|
21
|
-
const hash =
|
|
43
|
+
const hash = CachedRouterRoute.hashRequest(request);
|
|
22
44
|
if (hash === null) {
|
|
23
45
|
return;
|
|
24
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cached.router-route.js","sourceRoot":"","sources":["../../../../src/cache/cached.router-route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cached.router-route.js","sourceRoot":"","sources":["../../../../src/cache/cached.router-route.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AAExB,MAAM,OAAO,iBAAiB;IAI1B,YAA4B,UAA4B;QAA5B,eAAU,GAAV,UAAU,CAAkB;QAHhD,oCAA+B,GAAqC,EAAE,CAAC;IAK/E,CAAC;IAEM,MAAM,CAAC,WAAW,CAAC,OAAgB;QACtC,MAAM,IAAI,GAAG,CAAC,GAAQ,EAAE,EAAE;YACtB,MAAM,GAAG,GAAQ,EAAE,CAAC;YAEpB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,UAAU,GAAG;gBACzC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC;YAEH,OAAO,GAAG,CAAC;QACf,CAAC,CAAC;QAEF,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QAE/B,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAEvC,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;QAE9B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAEnD,IAAI,CAAC;YACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,OAAO,IAAI,CAAC;QAChB,CAAC;QAGD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,kCAAkC,CAAC,OAAgB;QAC/C,qBAAqB;QACrB,MAAM,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAEpD,IAAG,IAAI,KAAK,IAAI,EAAE,CAAC;YACf,OAAO;QACX,CAAC;QAED,oDAAoD;QACpD,OAAO,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,8BAA8B,CAAC,OAAgB,EAAE,eAAsB;QACnE,qBAAqB;QACrB,MAAM,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAEpD,IAAG,IAAI,KAAK,IAAI,EAAE,CAAC;YACf,OAAO;QACX,CAAC;QAED,4BAA4B;QAC5B,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC;IACjE,CAAC;CACJ"}
|
|
@@ -7,7 +7,7 @@ export declare class CachedRouterRoute {
|
|
|
7
7
|
[key: string]: string;
|
|
8
8
|
};
|
|
9
9
|
constructor(methodNode: MethodRouterNode);
|
|
10
|
-
|
|
10
|
+
static hashRequest(request: Request): string | null;
|
|
11
11
|
getCachedControllerMethodArguments(request: Request): any[] | undefined;
|
|
12
12
|
cacheControllerMethodArguments(request: Request, methodArguments: any[]): void;
|
|
13
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristine-ts/networking",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.329",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "dist/lib/esm/networking.module.js",
|
|
6
6
|
"main": "dist/lib/cjs/networking.module.js",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@pristine-ts/common": "^0.0.
|
|
24
|
-
"@pristine-ts/core": "^0.0.
|
|
25
|
-
"@pristine-ts/data-mapping": "^0.0.
|
|
23
|
+
"@pristine-ts/common": "^0.0.329",
|
|
24
|
+
"@pristine-ts/core": "^0.0.329",
|
|
25
|
+
"@pristine-ts/data-mapping": "^0.0.329",
|
|
26
26
|
"@pristine-ts/metadata": "^1.0.6",
|
|
27
|
-
"@pristine-ts/security": "^0.0.
|
|
28
|
-
"@pristine-ts/telemetry": "^0.0.
|
|
27
|
+
"@pristine-ts/security": "^0.0.329",
|
|
28
|
+
"@pristine-ts/telemetry": "^0.0.329",
|
|
29
29
|
"lodash": "^4.17.21"
|
|
30
30
|
},
|
|
31
31
|
"jest": {
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"src/*.{js,ts}"
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "cf32b74f53c5902d8ac94e356792dd510b0a6560"
|
|
66
66
|
}
|