@pristine-ts/networking 0.0.165 → 0.0.169
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/decorators/body.decorator.js +20 -1
- package/dist/lib/cjs/decorators/body.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/controller.decorator.js +13 -1
- package/dist/lib/cjs/decorators/controller.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/decorators.js +1 -1
- package/dist/lib/cjs/decorators/decorators.js.map +1 -1
- package/dist/lib/cjs/decorators/headers.decorator.js +20 -1
- package/dist/lib/cjs/decorators/headers.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/identity.decorator.js +20 -1
- package/dist/lib/cjs/decorators/identity.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/query-parameter.decorator.js +22 -1
- package/dist/lib/cjs/decorators/query-parameter.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/query-parameters.decorator.js +20 -1
- package/dist/lib/cjs/decorators/query-parameters.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/request.decorator.js +20 -1
- package/dist/lib/cjs/decorators/request.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/response-header.decorator.js +24 -2
- package/dist/lib/cjs/decorators/response-header.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/route-parameter.decorator.js +21 -1
- package/dist/lib/cjs/decorators/route-parameter.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/route.decorator.js +21 -1
- package/dist/lib/cjs/decorators/route.decorator.js.map +1 -1
- package/dist/lib/cjs/enrichers/router-response.enricher.js +4 -0
- package/dist/lib/cjs/enrichers/router-response.enricher.js.map +1 -1
- package/dist/lib/cjs/errors/errors.js +3 -1
- package/dist/lib/cjs/errors/errors.js.map +1 -1
- package/dist/lib/cjs/errors/http.error.js +1 -1
- package/dist/lib/cjs/errors/http.error.js.map +1 -1
- package/dist/lib/cjs/errors/method-router-adding.error.js +25 -0
- package/dist/lib/cjs/errors/method-router-adding.error.js.map +1 -0
- package/dist/lib/cjs/errors/path-router-adding.error.js +3 -2
- package/dist/lib/cjs/errors/path-router-adding.error.js.map +1 -1
- package/dist/lib/cjs/errors/path-router-instantiation.error.js +3 -2
- package/dist/lib/cjs/errors/path-router-instantiation.error.js.map +1 -1
- package/dist/lib/cjs/interfaces/interfaces.js +2 -2
- package/dist/lib/cjs/interfaces/interfaces.js.map +1 -1
- package/dist/lib/cjs/models/models.js +0 -1
- package/dist/lib/cjs/models/models.js.map +1 -1
- package/dist/lib/cjs/models/request.js +10 -4
- package/dist/lib/cjs/models/request.js.map +1 -1
- package/dist/lib/cjs/models/response.js +6 -0
- package/dist/lib/cjs/models/response.js.map +1 -1
- package/dist/lib/cjs/models/route.js +4 -0
- package/dist/lib/cjs/models/route.js.map +1 -1
- package/dist/lib/cjs/networking.module.js +0 -6
- package/dist/lib/cjs/networking.module.js.map +1 -1
- package/dist/lib/cjs/nodes/method-router.node.js +19 -4
- package/dist/lib/cjs/nodes/method-router.node.js.map +1 -1
- package/dist/lib/cjs/nodes/path-router.node.js +22 -12
- package/dist/lib/cjs/nodes/path-router.node.js.map +1 -1
- package/dist/lib/cjs/resolvers/body-parameter-decorator.resolver.js +18 -0
- package/dist/lib/cjs/resolvers/body-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/resolvers/controller-method-parameter-decorator.resolver.js +14 -0
- package/dist/lib/cjs/resolvers/controller-method-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/resolvers/headers-parameter-decorator.resolver.js +18 -0
- package/dist/lib/cjs/resolvers/headers-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/resolvers/identity-parameter-decorator.resolver.js +18 -0
- package/dist/lib/cjs/resolvers/identity-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/resolvers/query-parameter-decorator.resolver.js +19 -0
- package/dist/lib/cjs/resolvers/query-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/resolvers/query-parameters-decorator.resolver.js +18 -0
- package/dist/lib/cjs/resolvers/query-parameters-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/resolvers/route-parameter-decorator.resolver.js +18 -0
- package/dist/lib/cjs/resolvers/route-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/router.js +16 -0
- package/dist/lib/cjs/router.js.map +1 -1
- package/dist/lib/esm/decorators/body.decorator.js +20 -1
- package/dist/lib/esm/decorators/body.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/controller.decorator.js +13 -1
- package/dist/lib/esm/decorators/controller.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/decorators.js +1 -1
- package/dist/lib/esm/decorators/decorators.js.map +1 -1
- package/dist/lib/esm/decorators/headers.decorator.js +20 -1
- package/dist/lib/esm/decorators/headers.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/identity.decorator.js +20 -1
- package/dist/lib/esm/decorators/identity.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/query-parameter.decorator.js +22 -1
- package/dist/lib/esm/decorators/query-parameter.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/query-parameters.decorator.js +20 -1
- package/dist/lib/esm/decorators/query-parameters.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/request.decorator.js +20 -1
- package/dist/lib/esm/decorators/request.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/response-header.decorator.js +24 -2
- package/dist/lib/esm/decorators/response-header.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/route-parameter.decorator.js +21 -1
- package/dist/lib/esm/decorators/route-parameter.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/route.decorator.js +21 -1
- package/dist/lib/esm/decorators/route.decorator.js.map +1 -1
- package/dist/lib/esm/enrichers/router-response.enricher.js +4 -0
- package/dist/lib/esm/enrichers/router-response.enricher.js.map +1 -1
- package/dist/lib/esm/errors/errors.js +3 -1
- package/dist/lib/esm/errors/errors.js.map +1 -1
- package/dist/lib/esm/errors/http.error.js +1 -1
- package/dist/lib/esm/errors/http.error.js.map +1 -1
- package/dist/lib/esm/errors/method-router-adding.error.js +21 -0
- package/dist/lib/esm/errors/method-router-adding.error.js.map +1 -0
- package/dist/lib/esm/errors/path-router-adding.error.js +3 -2
- package/dist/lib/esm/errors/path-router-adding.error.js.map +1 -1
- package/dist/lib/esm/errors/path-router-instantiation.error.js +3 -2
- package/dist/lib/esm/errors/path-router-instantiation.error.js.map +1 -1
- package/dist/lib/esm/interfaces/interfaces.js +2 -2
- package/dist/lib/esm/interfaces/interfaces.js.map +1 -1
- package/dist/lib/esm/models/models.js +0 -1
- package/dist/lib/esm/models/models.js.map +1 -1
- package/dist/lib/esm/models/request.js +10 -4
- package/dist/lib/esm/models/request.js.map +1 -1
- package/dist/lib/esm/models/response.js +6 -0
- package/dist/lib/esm/models/response.js.map +1 -1
- package/dist/lib/esm/models/route.js +4 -0
- package/dist/lib/esm/models/route.js.map +1 -1
- package/dist/lib/esm/networking.module.js +0 -6
- package/dist/lib/esm/networking.module.js.map +1 -1
- package/dist/lib/esm/nodes/method-router.node.js +19 -4
- package/dist/lib/esm/nodes/method-router.node.js.map +1 -1
- package/dist/lib/esm/nodes/path-router.node.js +22 -12
- package/dist/lib/esm/nodes/path-router.node.js.map +1 -1
- package/dist/lib/esm/resolvers/body-parameter-decorator.resolver.js +18 -0
- package/dist/lib/esm/resolvers/body-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/resolvers/controller-method-parameter-decorator.resolver.js +14 -0
- package/dist/lib/esm/resolvers/controller-method-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/resolvers/headers-parameter-decorator.resolver.js +18 -0
- package/dist/lib/esm/resolvers/headers-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/resolvers/identity-parameter-decorator.resolver.js +18 -0
- package/dist/lib/esm/resolvers/identity-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/resolvers/query-parameter-decorator.resolver.js +19 -0
- package/dist/lib/esm/resolvers/query-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/resolvers/query-parameters-decorator.resolver.js +18 -0
- package/dist/lib/esm/resolvers/query-parameters-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/resolvers/route-parameter-decorator.resolver.js +18 -0
- package/dist/lib/esm/resolvers/route-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/router.js +16 -0
- package/dist/lib/esm/router.js.map +1 -1
- package/dist/types/decorators/body.decorator.d.ts +3 -0
- package/dist/types/decorators/controller.decorator.d.ts +4 -0
- package/dist/types/decorators/decorators.d.ts +1 -1
- package/dist/types/decorators/headers.decorator.d.ts +3 -0
- package/dist/types/decorators/identity.decorator.d.ts +3 -0
- package/dist/types/decorators/query-parameter.decorator.d.ts +4 -0
- package/dist/types/decorators/query-parameters.decorator.d.ts +3 -0
- package/dist/types/decorators/request.decorator.d.ts +3 -0
- package/dist/types/decorators/response-header.decorator.d.ts +7 -0
- package/dist/types/decorators/route-parameter.decorator.d.ts +4 -0
- package/dist/types/decorators/route.decorator.d.ts +6 -1
- package/dist/types/enrichers/router-response.enricher.d.ts +4 -0
- package/dist/types/errors/errors.d.ts +3 -1
- package/dist/types/errors/http.error.d.ts +1 -1
- package/dist/types/errors/method-router-adding.error.d.ts +10 -0
- package/dist/types/errors/path-router-adding.error.d.ts +4 -3
- package/dist/types/errors/path-router-instantiation.error.d.ts +4 -3
- package/dist/types/interfaces/controller-method-parameter-decorator-resolver.interface.d.ts +19 -2
- package/dist/types/interfaces/interfaces.d.ts +2 -2
- package/dist/types/interfaces/parameter-decorator.interface.d.ts +4 -0
- package/dist/types/interfaces/query-parameters-decorator.interface.d.ts +4 -0
- package/dist/types/interfaces/route-parameter-decorator.interface.d.ts +1 -1
- package/dist/types/interfaces/router.interface.d.ts +2 -2
- package/dist/types/models/models.d.ts +0 -1
- package/dist/types/models/request.d.ts +16 -4
- package/dist/types/models/response.d.ts +15 -0
- package/dist/types/models/route.d.ts +4 -0
- package/dist/types/nodes/method-router.node.d.ts +17 -4
- package/dist/types/nodes/path-router.node.d.ts +11 -7
- package/dist/types/nodes/router.node.d.ts +3 -3
- package/dist/types/resolvers/body-parameter-decorator.resolver.d.ts +22 -2
- package/dist/types/resolvers/controller-method-parameter-decorator.resolver.d.ts +14 -0
- package/dist/types/resolvers/headers-parameter-decorator.resolver.d.ts +22 -2
- package/dist/types/resolvers/identity-parameter-decorator.resolver.d.ts +22 -2
- package/dist/types/resolvers/query-parameter-decorator.resolver.d.ts +23 -2
- package/dist/types/resolvers/query-parameters-decorator.resolver.d.ts +22 -2
- package/dist/types/resolvers/route-parameter-decorator.resolver.d.ts +22 -2
- package/dist/types/router.d.ts +12 -0
- package/package.json +5 -5
- package/dist/lib/cjs/enums/enums.js +0 -1
- package/dist/lib/cjs/enums/enums.js.map +0 -1
- package/dist/lib/cjs/models/error-response-body.js +0 -7
- package/dist/lib/cjs/models/error-response-body.js.map +0 -1
- package/dist/lib/esm/enums/enums.js +0 -1
- package/dist/lib/esm/enums/enums.js.map +0 -1
- package/dist/lib/esm/models/error-response-body.js +0 -3
- package/dist/lib/esm/models/error-response-body.js.map +0 -1
- package/dist/types/enums/enums.d.ts +0 -0
- package/dist/types/models/error-response-body.d.ts +0 -4
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PathRouterInstantiationError = void 0;
|
|
4
|
+
const common_1 = require("@pristine-ts/common");
|
|
4
5
|
/**
|
|
5
|
-
* This Error is thrown when there's an error that happens when the networking is being initialized
|
|
6
|
+
* This Error is thrown when there's an error that happens when the networking is being initialized.
|
|
7
|
+
* It is thrown when an error occurs when trying to instantiate a PathRouterNode.
|
|
6
8
|
*/
|
|
7
|
-
const common_1 = require("@pristine-ts/common");
|
|
8
9
|
class PathRouterInstantiationError extends common_1.LoggableError {
|
|
9
10
|
constructor(message, path, parent) {
|
|
10
11
|
super(message, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-router-instantiation.error.js","sourceRoot":"","sources":["../../../../src/errors/path-router-instantiation.error.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"path-router-instantiation.error.js","sourceRoot":"","sources":["../../../../src/errors/path-router-instantiation.error.ts"],"names":[],"mappings":";;;AAAA,gDAAkD;AAGlD;;;GAGG;AACH,MAAa,4BAA6B,SAAQ,sBAAa;IAE3D,YAAmB,OAAe,EAAE,IAAY,EAAE,MAAuB;QACrE,KAAK,CAAC,OAAO,EAAE;YACX,IAAI;YACJ,MAAM;SACT,CAAC,CAAC;QAEH,gCAAgC;QAChC,kDAAkD;QAClD,gIAAgI;QAChI,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,4BAA4B,CAAC,SAAS,CAAC,CAAC;IAAI,CAAC;CAChF;AAZD,oEAYC"}
|
|
@@ -18,9 +18,9 @@ __exportStar(require("./parameter-decorator.interface"), exports);
|
|
|
18
18
|
__exportStar(require("./query-parameter-decorator.interface"), exports);
|
|
19
19
|
__exportStar(require("./query-parameters-decorator.interface"), exports);
|
|
20
20
|
__exportStar(require("./request-parameter-decorator.interface"), exports);
|
|
21
|
-
__exportStar(require("./router-request-enricher.interface"), exports);
|
|
22
|
-
__exportStar(require("./router-response-enricher.interface"), exports);
|
|
23
21
|
__exportStar(require("./route-method-decorator.interface"), exports);
|
|
24
22
|
__exportStar(require("./route-parameter-decorator.interface"), exports);
|
|
25
23
|
__exportStar(require("./router.interface"), exports);
|
|
24
|
+
__exportStar(require("./router-request-enricher.interface"), exports);
|
|
25
|
+
__exportStar(require("./router-response-enricher.interface"), exports);
|
|
26
26
|
//# sourceMappingURL=interfaces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/interfaces/interfaces.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uEAAqD;AACrD,6FAA2E;AAC3E,0EAAwD;AACxD,6EAA2D;AAC3D,kEAAgD;AAChD,wEAAsD;AACtD,yEAAuD;AACvD,0EAAwD;AACxD,
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/interfaces/interfaces.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uEAAqD;AACrD,6FAA2E;AAC3E,0EAAwD;AACxD,6EAA2D;AAC3D,kEAAgD;AAChD,wEAAsD;AACtD,yEAAuD;AACvD,0EAAwD;AACxD,qEAAmD;AACnD,wEAAsD;AACtD,qDAAmC;AACnC,sEAAoD;AACpD,uEAAqD"}
|
|
@@ -10,7 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./error-response-body"), exports);
|
|
14
13
|
__exportStar(require("./request"), exports);
|
|
15
14
|
__exportStar(require("./response"), exports);
|
|
16
15
|
__exportStar(require("./route"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/models/models.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/models/models.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA0B;AAC1B,6CAA2B;AAC3B,0CAAwB"}
|
|
@@ -7,7 +7,13 @@ exports.Request = void 0;
|
|
|
7
7
|
class Request {
|
|
8
8
|
constructor(requestInterface) {
|
|
9
9
|
var _a, _b;
|
|
10
|
+
/**
|
|
11
|
+
* The headers of the request.
|
|
12
|
+
*/
|
|
10
13
|
this.headers = {};
|
|
14
|
+
/**
|
|
15
|
+
* The body of the request.
|
|
16
|
+
*/
|
|
11
17
|
this.body = {};
|
|
12
18
|
this.httpMethod = requestInterface.httpMethod;
|
|
13
19
|
this.url = requestInterface.url;
|
|
@@ -17,8 +23,8 @@ class Request {
|
|
|
17
23
|
/**
|
|
18
24
|
* This method sets a header parameter in the Request.
|
|
19
25
|
*
|
|
20
|
-
* @param name
|
|
21
|
-
* @param value
|
|
26
|
+
* @param name The name of the header.
|
|
27
|
+
* @param value The value of the header.
|
|
22
28
|
*/
|
|
23
29
|
setHeader(name, value) {
|
|
24
30
|
this.headers[name] = value;
|
|
@@ -26,7 +32,7 @@ class Request {
|
|
|
26
32
|
/**
|
|
27
33
|
* This method returns whether or not the header exists in the Request.
|
|
28
34
|
*
|
|
29
|
-
* @param name
|
|
35
|
+
* @param name The name of the header.
|
|
30
36
|
*/
|
|
31
37
|
hasHeader(name) {
|
|
32
38
|
return this.headers.hasOwnProperty(name);
|
|
@@ -34,7 +40,7 @@ class Request {
|
|
|
34
40
|
/**
|
|
35
41
|
* This method returns the header corresponding to the name or undefined if it doesn't exist.
|
|
36
42
|
*
|
|
37
|
-
* @param name
|
|
43
|
+
* @param name The name of the header.
|
|
38
44
|
*/
|
|
39
45
|
getHeader(name) {
|
|
40
46
|
return this.headers[name];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/models/request.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAa,OAAO;
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/models/request.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAa,OAAO;IAqBhB,YAAY,gBAAkC;;QAV9C;;WAEG;QACH,YAAO,GAA8B,EAAE,CAAC;QAExC;;WAEG;QACH,SAAI,GAAQ,EAAE,CAAC;QAGX,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC,UAAU,CAAC;QAC9C,IAAI,CAAC,GAAG,GAAG,gBAAgB,CAAC,GAAG,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,MAAA,gBAAgB,CAAC,OAAO,mCAAI,EAAE,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,MAAA,gBAAgB,CAAC,IAAI,mCAAI,EAAE,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,IAAY,EAAE,KAAa;QACjC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,IAAY;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,IAAY;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACJ;AAvDD,0BAuDC"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Response = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* This Response object represents the class used internally that represents a Response.
|
|
6
|
+
*/
|
|
4
7
|
class Response {
|
|
5
8
|
constructor() {
|
|
9
|
+
/**
|
|
10
|
+
* The status code of the response. By default we return a 200.
|
|
11
|
+
*/
|
|
6
12
|
this.status = 200;
|
|
7
13
|
}
|
|
8
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/models/response.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/models/response.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,QAAQ;IAArB;QACI;;WAEG;QACH,WAAM,GAAW,GAAG,CAAC;IAgBzB,CAAC;CAAA;AApBD,4BAoBC"}
|
|
@@ -5,6 +5,10 @@ exports.Route = void 0;
|
|
|
5
5
|
* This class represents a Route and how it can be routed to the proper controller method.
|
|
6
6
|
*/
|
|
7
7
|
class Route {
|
|
8
|
+
/**
|
|
9
|
+
* @param controllerInstantiationToken The instantiation token of the controller. Usually this will be the controller's constructor name.
|
|
10
|
+
* @param methodPropertyKey The name of the method that corresponds to the route in the controller.
|
|
11
|
+
*/
|
|
8
12
|
constructor(controllerInstantiationToken, methodPropertyKey) {
|
|
9
13
|
this.controllerInstantiationToken = controllerInstantiationToken;
|
|
10
14
|
this.methodPropertyKey = methodPropertyKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../src/models/route.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../src/models/route.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,KAAK;IAWd;;;OAGG;IACH,YAA4B,4BAAiC,EAAkB,iBAAyB;QAA5E,iCAA4B,GAA5B,4BAA4B,CAAK;QAAkB,sBAAiB,GAAjB,iBAAiB,CAAQ;QAdxG;;WAEG;QACH,oBAAe,GAAkC,EAAE,CAAC;IAYpD,CAAC;CACJ;AAjBD,sBAiBC"}
|
|
@@ -16,7 +16,6 @@ const security_1 = require("@pristine-ts/security");
|
|
|
16
16
|
const telemetry_1 = require("@pristine-ts/telemetry");
|
|
17
17
|
__exportStar(require("./decorators/decorators"), exports);
|
|
18
18
|
__exportStar(require("./enrichers/enrichers"), exports);
|
|
19
|
-
//export * from "./enums/enums";
|
|
20
19
|
__exportStar(require("./errors/errors"), exports);
|
|
21
20
|
__exportStar(require("./interfaces/interfaces"), exports);
|
|
22
21
|
__exportStar(require("./models/models"), exports);
|
|
@@ -26,11 +25,6 @@ __exportStar(require("./utils/utils"), exports);
|
|
|
26
25
|
__exportStar(require("./router"), exports);
|
|
27
26
|
exports.NetworkingModule = {
|
|
28
27
|
keyname: networking_module_keyname_1.NetworkingModuleKeyname,
|
|
29
|
-
/**
|
|
30
|
-
* This property allows you to custom register specific services. For example, you can assign a tag or use a factory
|
|
31
|
-
* to instantiate a specific class.
|
|
32
|
-
*/
|
|
33
|
-
providerRegistrations: [],
|
|
34
28
|
importModules: [
|
|
35
29
|
security_1.SecurityModule,
|
|
36
30
|
telemetry_1.TelemetryModule,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"networking.module.js","sourceRoot":"","sources":["../../../src/networking.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,2EAAoE;AACpE,oDAAqD;AACrD,sDAAuD;AAEvD,0DAAwC;AACxC,wDAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"networking.module.js","sourceRoot":"","sources":["../../../src/networking.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,2EAAoE;AACpE,oDAAqD;AACrD,sDAAuD;AAEvD,0DAAwC;AACxC,wDAAsC;AACtC,kDAAgC;AAChC,0DAAwC;AACxC,kDAAgC;AAChC,gDAA8B;AAC9B,wDAAsC;AACtC,gDAA8B;AAE9B,2CAAyB;AAEZ,QAAA,gBAAgB,GAAoB;IAC7C,OAAO,EAAE,mDAAuB;IAChC,aAAa,EAAE;QACX,yBAAc;QACd,2BAAe;KAClB;IACD,wBAAwB,EAAE,EAEzB;CACJ,CAAA"}
|
|
@@ -2,10 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MethodRouterNode = void 0;
|
|
4
4
|
const router_node_1 = require("./router.node");
|
|
5
|
+
const method_router_adding_error_1 = require("../errors/method-router-adding.error");
|
|
5
6
|
/**
|
|
6
7
|
* This class represents the Leaf node of the RouteTree.
|
|
8
|
+
* It will always have a parent node that will be a PathRouterNode.
|
|
7
9
|
*/
|
|
8
10
|
class MethodRouterNode extends router_node_1.RouterNode {
|
|
11
|
+
/**
|
|
12
|
+
* @param parent The parent node of the current node.
|
|
13
|
+
* @param method The http method of the current method node.
|
|
14
|
+
* @param route The route associated with the current node.
|
|
15
|
+
* @param levelFromRoot The depth level from the root node.
|
|
16
|
+
*/
|
|
9
17
|
constructor(parent, method, route, levelFromRoot) {
|
|
10
18
|
super();
|
|
11
19
|
this.method = method;
|
|
@@ -13,6 +21,11 @@ class MethodRouterNode extends router_node_1.RouterNode {
|
|
|
13
21
|
this.levelFromRoot = levelFromRoot;
|
|
14
22
|
this.parent = parent;
|
|
15
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns whether or not the node matches.
|
|
26
|
+
* This verification is made by verify the http method matches with the http method of the current node.
|
|
27
|
+
* @param method The http method to compare.
|
|
28
|
+
*/
|
|
16
29
|
matches(method) {
|
|
17
30
|
return this.method === method;
|
|
18
31
|
}
|
|
@@ -24,20 +37,22 @@ class MethodRouterNode extends router_node_1.RouterNode {
|
|
|
24
37
|
}
|
|
25
38
|
/**
|
|
26
39
|
* This method adds all the required nodes to match the splitPaths and the method.
|
|
27
|
-
*
|
|
40
|
+
* Since a MethodRouterNode is a leaf node, you can't add anything after it, this method therefore doesn't do anything.
|
|
28
41
|
* @param splitPaths
|
|
29
42
|
* @param method
|
|
30
43
|
* @param route
|
|
31
44
|
*/
|
|
32
45
|
add(splitPaths, method, route) {
|
|
46
|
+
throw new method_router_adding_error_1.MethodRouterAddingError("Impossible to add a child node to a MethodRouterNode.", splitPaths, method, route, this);
|
|
33
47
|
}
|
|
34
48
|
/**
|
|
35
|
-
* This method
|
|
49
|
+
* This method receives an array of path and recursively calls its children if this node matches
|
|
50
|
+
* the first splitPath. If the node is a MethodRouterNode, it checks to see if the method matches. If yes,
|
|
36
51
|
* it returns itself as the node found. This method should always return a MethodRouterNode. However, Typescript
|
|
37
52
|
* doesn't like these recursive imports so we return the base class
|
|
38
53
|
*
|
|
39
|
-
* @param splitPaths
|
|
40
|
-
* @param method
|
|
54
|
+
* @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
|
|
55
|
+
* @param method The http method for which to find a node.
|
|
41
56
|
*/
|
|
42
57
|
find(splitPaths, method) {
|
|
43
58
|
if (this.parent.isCatchAll()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-router.node.js","sourceRoot":"","sources":["../../../../src/nodes/method-router.node.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;
|
|
1
|
+
{"version":3,"file":"method-router.node.js","sourceRoot":"","sources":["../../../../src/nodes/method-router.node.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;AAIzC,qFAA6E;AAE7E;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,wBAAU;IAC5C;;;;;OAKG;IACH,YAAmB,MAAsB,EAAkB,MAA2B,EAAkB,KAAY,EAAkB,aAAqB;QACvJ,KAAK,EAAE,CAAC;QAD+C,WAAM,GAAN,MAAM,CAAqB;QAAkB,UAAK,GAAL,KAAK,CAAO;QAAkB,kBAAa,GAAb,aAAa,CAAQ;QAGvJ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,MAA2B;QAC/B,OAAO,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,UAAU;QACN,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;;OAMG;IACH,GAAG,CAAC,UAAoB,EAAE,MAA2B,EAAE,KAAY;QAC/D,MAAM,IAAI,oDAAuB,CAAC,uDAAuD,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAChI,CAAC;IAED;;;;;;;;OAQG;IACH,IAAI,CAAC,UAAoB,EAAE,MAA2B;QAClD,IAAG,IAAI,CAAC,MAAO,CAAC,UAAU,EAAE,EAAE;YAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;SAC7C;QAED,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3E,CAAC;CACJ;AAxDD,4CAwDC"}
|
|
@@ -9,6 +9,10 @@ const path_router_adding_error_1 = require("../errors/path-router-adding.error")
|
|
|
9
9
|
* This class represents a Path Node in the Router Node. It can never be a leaf node and will always have children.
|
|
10
10
|
*/
|
|
11
11
|
class PathRouterNode extends router_node_1.RouterNode {
|
|
12
|
+
/**
|
|
13
|
+
* @param path The path associated with the current node.
|
|
14
|
+
* @param parent The parent node of the current node.
|
|
15
|
+
*/
|
|
12
16
|
constructor(path, parent) {
|
|
13
17
|
super();
|
|
14
18
|
this.path = path;
|
|
@@ -20,9 +24,9 @@ class PathRouterNode extends router_node_1.RouterNode {
|
|
|
20
24
|
/**
|
|
21
25
|
* This method adds all the required nodes to match the splitPaths and the method.
|
|
22
26
|
*
|
|
23
|
-
* @param splitPaths
|
|
24
|
-
* @param method
|
|
25
|
-
* @param route
|
|
27
|
+
* @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
|
|
28
|
+
* @param method The http method for this route.
|
|
29
|
+
* @param route The route.
|
|
26
30
|
*/
|
|
27
31
|
add(splitPaths, method, route, levelFromRoot) {
|
|
28
32
|
// Check to make sure that the first split path matches the current node
|
|
@@ -37,13 +41,15 @@ class PathRouterNode extends router_node_1.RouterNode {
|
|
|
37
41
|
if (matchedMethodRouterNodeChild !== undefined) {
|
|
38
42
|
throw new path_router_adding_error_1.PathRouterAddingError("There is already an HTTP Method associated with this path.", splitPaths, method, route, this);
|
|
39
43
|
}
|
|
44
|
+
// Add a new child node of type MethodRouterNode for this new http method.
|
|
40
45
|
this.children.push(new method_router_node_1.MethodRouterNode(this, method, route, levelFromRoot + 1));
|
|
41
46
|
return;
|
|
42
47
|
}
|
|
43
48
|
// Loop over our children that are of PathRouterNode and check if the next path matches
|
|
44
49
|
const matchedChild = this.children.filter(child => child instanceof PathRouterNode).find((child) => child.matches(splitPaths[1]));
|
|
45
|
-
// If there's a matched child, call the add
|
|
50
|
+
// If there's a matched child, call the add method on it and return.
|
|
46
51
|
if (matchedChild !== undefined) {
|
|
52
|
+
// Remove the first part of the path as it is used by the current node.
|
|
47
53
|
matchedChild.add(splitPaths.slice(1), method, route, levelFromRoot + 1);
|
|
48
54
|
return;
|
|
49
55
|
}
|
|
@@ -51,6 +57,7 @@ class PathRouterNode extends router_node_1.RouterNode {
|
|
|
51
57
|
const pathRouterNode = new PathRouterNode(splitPaths[1], this);
|
|
52
58
|
this.children.push(pathRouterNode);
|
|
53
59
|
// Then, call add on the latest pathRouterNode child
|
|
60
|
+
// Remove the first part of the path as it is used by the current node.
|
|
54
61
|
pathRouterNode.add(splitPaths.slice(1), method, route, levelFromRoot + 1);
|
|
55
62
|
return;
|
|
56
63
|
}
|
|
@@ -60,8 +67,8 @@ class PathRouterNode extends router_node_1.RouterNode {
|
|
|
60
67
|
* it returns itself as the node found. This method should always return a MethodRouterNode. However, Typescript
|
|
61
68
|
* doesn't like these recursive imports so we return the base class
|
|
62
69
|
*
|
|
63
|
-
* @param splitPaths
|
|
64
|
-
* @param method
|
|
70
|
+
* @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
|
|
71
|
+
* @param method The http method for which to find a node.
|
|
65
72
|
*/
|
|
66
73
|
find(splitPaths, method) {
|
|
67
74
|
// If splitPaths is 0 or if the first path doesn't match this current node, we return
|
|
@@ -69,7 +76,8 @@ class PathRouterNode extends router_node_1.RouterNode {
|
|
|
69
76
|
return null;
|
|
70
77
|
}
|
|
71
78
|
const foundChildren = [];
|
|
72
|
-
// Since we checked above if we didn't match, it means we match.
|
|
79
|
+
// Since we checked above if we didn't match, it means we match.
|
|
80
|
+
// We check if one of our children matches the next part of the path.
|
|
73
81
|
for (const child of this.children) {
|
|
74
82
|
const foundChild = child.find(splitPaths.slice(1), method);
|
|
75
83
|
if (foundChild !== null) {
|
|
@@ -91,12 +99,14 @@ class PathRouterNode extends router_node_1.RouterNode {
|
|
|
91
99
|
/**
|
|
92
100
|
* This httpMethod navigates the tree upwards and returns all the routeParameters
|
|
93
101
|
*
|
|
94
|
-
* @param splitPaths
|
|
102
|
+
* @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
|
|
95
103
|
*/
|
|
96
104
|
getRouteParameters(splitPaths) {
|
|
97
105
|
let parameters = {};
|
|
98
106
|
if (this.matches(splitPaths[0])) {
|
|
99
|
-
// If the current path is a
|
|
107
|
+
// If the current path is a path parameter
|
|
108
|
+
// We support both ways of setting a path parameter, either curly brackets, or colons
|
|
109
|
+
// ie: services/{serviceId} or service/:serviceId
|
|
100
110
|
if (this.path.startsWith("/{") && this.path.endsWith("}")) {
|
|
101
111
|
const name = this.path.slice(2, this.path.length - 1);
|
|
102
112
|
parameters[name] = splitPaths[0].slice(1, splitPaths[0].length);
|
|
@@ -120,14 +130,14 @@ class PathRouterNode extends router_node_1.RouterNode {
|
|
|
120
130
|
return this.path.startsWith("/*");
|
|
121
131
|
}
|
|
122
132
|
/**
|
|
123
|
-
* This method returns whether or not this pathRouterNode represents a route parameter, e.g.: /{id} or
|
|
133
|
+
* This method returns whether or not this pathRouterNode represents a route parameter, e.g.: /{id} or /:id
|
|
124
134
|
*/
|
|
125
135
|
isRouteParameter() {
|
|
126
|
-
// If the current path is a parameter
|
|
136
|
+
// If the current path is a path parameter, meaning has services/{id-of-service}
|
|
127
137
|
if (this.path.startsWith("/{") && this.path.endsWith("}")) {
|
|
128
138
|
return true;
|
|
129
139
|
}
|
|
130
|
-
// We also support parameter
|
|
140
|
+
// We also support path parameter written as services/:id-of-service
|
|
131
141
|
if (this.path.startsWith("/:")) {
|
|
132
142
|
return true;
|
|
133
143
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-router.node.js","sourceRoot":"","sources":["../../../../src/nodes/path-router.node.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;AAEzC,6DAAsD;AAEtD,+FAAuF;AACvF,iFAAyE;AAEzE;;GAEG;AACH,MAAa,cAAe,SAAQ,wBAAU;IAC1C,YAAmC,IAAY,EAAE,MAAuB;QACpE,KAAK,EAAE,CAAC;QADuB,SAAI,GAAJ,IAAI,CAA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AED,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,IAAY;QAChB,IAAG,IAAI,CAAC,UAAU,EAAE,EAAE;YAClB,OAAO,IAAI,CAAC;SACf;QAED,IAAI,IAAI,CAAC,gBAAgB,EAAE,EAAE;YACzB,OAAO,IAAI,CAAC;SACf;QAED,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;IAC9B,CAAC;CACJ;AAtLD,wCAsLC"}
|
|
@@ -11,11 +11,29 @@ require("reflect-metadata");
|
|
|
11
11
|
const tsyringe_1 = require("tsyringe");
|
|
12
12
|
const common_1 = require("@pristine-ts/common");
|
|
13
13
|
const networking_module_keyname_1 = require("../networking.module.keyname");
|
|
14
|
+
/**
|
|
15
|
+
* The BodyParameterDecoratorResolver resolves the value of the body of the request so that it can be injected it into the
|
|
16
|
+
* parameter of the route of the controller that was annotated with the @body decorator.
|
|
17
|
+
* It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
|
|
18
|
+
*/
|
|
14
19
|
let BodyParameterDecoratorResolver = class BodyParameterDecoratorResolver {
|
|
20
|
+
/**
|
|
21
|
+
* Resolves the value of the body of the request.
|
|
22
|
+
* The router than injects that value into the parameter of the controller method.
|
|
23
|
+
* @param methodArgument The method argument created by the decorator.
|
|
24
|
+
* @param request The request
|
|
25
|
+
* @param routeParameters The router parameters
|
|
26
|
+
* @param identity The identity making the request
|
|
27
|
+
*/
|
|
15
28
|
resolve(methodArgument, request, routeParameters, identity) {
|
|
16
29
|
var _a;
|
|
17
30
|
return Promise.resolve((_a = request.body) !== null && _a !== void 0 ? _a : null);
|
|
18
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns whether or not the resolver support such a method argument.
|
|
34
|
+
* Usually we will check the methodArgument.type field to determine if it is a supported type.
|
|
35
|
+
* @param methodArgument
|
|
36
|
+
*/
|
|
19
37
|
supports(methodArgument) {
|
|
20
38
|
return methodArgument && methodArgument.hasOwnProperty("type") && methodArgument.type === "body";
|
|
21
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body-parameter-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/body-parameter-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4BAAyB;AACzB,uCAAoC;AAGpC,gDAAmG;AACnG,4EAAqE;
|
|
1
|
+
{"version":3,"file":"body-parameter-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/body-parameter-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4BAAyB;AACzB,uCAAoC;AAGpC,gDAAmG;AACnG,4EAAqE;AAIrE;;;;GAIG;AAIH,IAAa,8BAA8B,GAA3C,MAAa,8BAA8B;IAEvC;;;;;;;OAOG;IACH,OAAO,CAAC,cAA+C,EAC/C,OAAgB,EAChB,eAAwC,EACxC,QAA4B;;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAA,OAAO,CAAC,IAAI,mCAAI,IAAI,CAAC,CAAC;IACjD,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,cAA2C;QAChD,OAAO,cAAc,IAAI,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,KAAK,MAAM,CAAC;IACrG,CAAC;CACJ,CAAA;AAzBY,8BAA8B;IAH1C,qBAAY,CAAC,mDAAuB,CAAC;IACrC,YAAG,CAAC,iCAAwB,CAAC,gCAAgC,CAAC;IAC9D,qBAAU,EAAE;GACA,8BAA8B,CAyB1C;AAzBY,wEAA8B"}
|
|
@@ -15,10 +15,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.ControllerMethodParameterDecoratorResolver = void 0;
|
|
16
16
|
const tsyringe_1 = require("tsyringe");
|
|
17
17
|
const common_1 = require("@pristine-ts/common");
|
|
18
|
+
/**
|
|
19
|
+
* This service calls the resolvers to resolve the value to be injected in the parameter of a method.
|
|
20
|
+
*/
|
|
18
21
|
let ControllerMethodParameterDecoratorResolver = class ControllerMethodParameterDecoratorResolver {
|
|
22
|
+
/**
|
|
23
|
+
* This service calls the resolvers to resolve the value to be injected in the parameter of a method.
|
|
24
|
+
* @param methodParameterDecoratorResolvers The parameter decorator resolvers. All services with the tag ServiceDefinitionTagEnum.MethodParameterDecoratorResolver will be automatically injected here.
|
|
25
|
+
*/
|
|
19
26
|
constructor(methodParameterDecoratorResolvers) {
|
|
20
27
|
this.methodParameterDecoratorResolvers = methodParameterDecoratorResolvers;
|
|
21
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* This method calls the parameter decorator resolver that supports the type of the decorator and resolves the value to be injected in the parameter.
|
|
31
|
+
* @param methodArgument The method argument created by the decorator.
|
|
32
|
+
* @param request The request
|
|
33
|
+
* @param routeParameters The router parameters
|
|
34
|
+
* @param identity The identity making the request
|
|
35
|
+
*/
|
|
22
36
|
resolve(methodArgument, request, routeParameters, identity) {
|
|
23
37
|
for (let methodParameterDecoratorResolver of this.methodParameterDecoratorResolvers) {
|
|
24
38
|
if (methodParameterDecoratorResolver.supports(methodArgument)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-method-parameter-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/controller-method-parameter-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAA+C;AAC/C,gDAAgF;
|
|
1
|
+
{"version":3,"file":"controller-method-parameter-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/controller-method-parameter-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAA+C;AAC/C,gDAAgF;AAKhF;;GAEG;AAEH,IAAa,0CAA0C,GAAvD,MAAa,0CAA0C;IACnD;;;OAGG;IACH,YAAmG,iCAAwF;QAAxF,sCAAiC,GAAjC,iCAAiC,CAAuD;IAC3L,CAAC;IAGD;;;;;;OAMG;IACI,OAAO,CAAC,cAA2C,EAC3C,OAAgB,EAChB,eAA0C,EAC1C,QAA4B;QAEvC,KAAK,IAAI,gCAAgC,IAAI,IAAI,CAAC,iCAAiC,EAAE;YACjF,IAAG,gCAAgC,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;gBAC1D,OAAO,gCAAgC,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;aACvG;SACJ;QAED,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;CACJ,CAAA;AA7BY,0CAA0C;IADtD,qBAAU,EAAE;IAMI,WAAA,oBAAS,CAAC,iCAAwB,CAAC,gCAAgC,CAAC,CAAA;;GALxE,0CAA0C,CA6BtD;AA7BY,gGAA0C"}
|
|
@@ -11,11 +11,29 @@ require("reflect-metadata");
|
|
|
11
11
|
const tsyringe_1 = require("tsyringe");
|
|
12
12
|
const common_1 = require("@pristine-ts/common");
|
|
13
13
|
const networking_module_keyname_1 = require("../networking.module.keyname");
|
|
14
|
+
/**
|
|
15
|
+
* The HeadersParameterDecoratorResolver resolves the value of the headers of the request so that it can be injected it into the
|
|
16
|
+
* parameter of the route of the controller that was annotated with the @headers decorator.
|
|
17
|
+
* It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
|
|
18
|
+
*/
|
|
14
19
|
let HeadersParameterDecoratorResolver = class HeadersParameterDecoratorResolver {
|
|
20
|
+
/**
|
|
21
|
+
* Resolves the value of the headers of the request.
|
|
22
|
+
* The router than injects that value into the parameter of the controller method.
|
|
23
|
+
* @param methodArgument The method argument created by the decorator.
|
|
24
|
+
* @param request The request
|
|
25
|
+
* @param routeParameters The router parameters
|
|
26
|
+
* @param identity The identity making the request
|
|
27
|
+
*/
|
|
15
28
|
resolve(methodArgument, request, routeParameters, identity) {
|
|
16
29
|
var _a;
|
|
17
30
|
return Promise.resolve((_a = request.headers) !== null && _a !== void 0 ? _a : null);
|
|
18
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns whether or not the resolver support such a method argument.
|
|
34
|
+
* Usually we will check the methodArgument.type field to determine if it is a supported type.
|
|
35
|
+
* @param methodArgument
|
|
36
|
+
*/
|
|
19
37
|
supports(methodArgument) {
|
|
20
38
|
return methodArgument && methodArgument.hasOwnProperty("type") && methodArgument.type === "headers";
|
|
21
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headers-parameter-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/headers-parameter-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4BAAyB;AACzB,uCAAoC;AAGpC,gDAAmG;AACnG,4EAAqE;
|
|
1
|
+
{"version":3,"file":"headers-parameter-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/headers-parameter-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4BAAyB;AACzB,uCAAoC;AAGpC,gDAAmG;AACnG,4EAAqE;AAIrE;;;;GAIG;AAIH,IAAa,iCAAiC,GAA9C,MAAa,iCAAiC;IAE1C;;;;;;;OAOG;IACH,OAAO,CAAC,cAAkD,EAClD,OAAgB,EAChB,eAAwC,EACxC,QAA4B;;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAA,OAAO,CAAC,OAAO,mCAAI,IAAI,CAAC,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,cAA2C;QAChD,OAAO,cAAc,IAAI,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,KAAK,SAAS,CAAC;IACxG,CAAC;CACJ,CAAA;AAzBY,iCAAiC;IAH7C,qBAAY,CAAC,mDAAuB,CAAC;IACrC,YAAG,CAAC,iCAAwB,CAAC,gCAAgC,CAAC;IAC9D,qBAAU,EAAE;GACA,iCAAiC,CAyB7C;AAzBY,8EAAiC"}
|
|
@@ -11,10 +11,28 @@ require("reflect-metadata");
|
|
|
11
11
|
const tsyringe_1 = require("tsyringe");
|
|
12
12
|
const common_1 = require("@pristine-ts/common");
|
|
13
13
|
const networking_module_keyname_1 = require("../networking.module.keyname");
|
|
14
|
+
/**
|
|
15
|
+
* The IdentityParameterDecoratorResolver resolves the value of the identity (parsed by the authenticator) of the request
|
|
16
|
+
* so that it can be injected it into the parameter of the route of the controller that was annotated with the @identity decorator.
|
|
17
|
+
* It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
|
|
18
|
+
*/
|
|
14
19
|
let IdentityParameterDecoratorResolver = class IdentityParameterDecoratorResolver {
|
|
20
|
+
/**
|
|
21
|
+
* Resolves the value of the identity of the request.
|
|
22
|
+
* The router than injects that value into the parameter of the controller method.
|
|
23
|
+
* @param methodArgument The method argument created by the decorator.
|
|
24
|
+
* @param request The request
|
|
25
|
+
* @param routeParameters The router parameters
|
|
26
|
+
* @param identity The identity making the request
|
|
27
|
+
*/
|
|
15
28
|
resolve(methodArgument, request, routeParameters, identity) {
|
|
16
29
|
return Promise.resolve(identity !== null && identity !== void 0 ? identity : null);
|
|
17
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns whether or not the resolver support such a method argument.
|
|
33
|
+
* Usually we will check the methodArgument.type field to determine if it is a supported type.
|
|
34
|
+
* @param methodArgument
|
|
35
|
+
*/
|
|
18
36
|
supports(methodArgument) {
|
|
19
37
|
return methodArgument && methodArgument.hasOwnProperty("type") && methodArgument.type === "identity";
|
|
20
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-parameter-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/identity-parameter-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4BAAyB;AACzB,uCAAoC;AAGpC,gDAAmG;AACnG,4EAAqE;
|
|
1
|
+
{"version":3,"file":"identity-parameter-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/identity-parameter-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4BAAyB;AACzB,uCAAoC;AAGpC,gDAAmG;AACnG,4EAAqE;AAIrE;;;;GAIG;AAIH,IAAa,kCAAkC,GAA/C,MAAa,kCAAkC;IAE3C;;;;;;;OAOG;IACH,OAAO,CAAC,cAAmD,EACnD,OAAgB,EAChB,eAAwC,EACxC,QAA4B;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,cAA2C;QAChD,OAAO,cAAc,IAAI,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,KAAK,UAAU,CAAC;IACzG,CAAC;CACJ,CAAA;AAzBY,kCAAkC;IAH9C,qBAAY,CAAC,mDAAuB,CAAC;IACrC,YAAG,CAAC,iCAAwB,CAAC,gCAAgC,CAAC;IAC9D,qBAAU,EAAE;GACA,kCAAkC,CAyB9C;AAzBY,gFAAkC"}
|
|
@@ -14,12 +14,31 @@ const tsyringe_1 = require("tsyringe");
|
|
|
14
14
|
const common_1 = require("@pristine-ts/common");
|
|
15
15
|
const networking_module_keyname_1 = require("../networking.module.keyname");
|
|
16
16
|
const url_parse_1 = __importDefault(require("url-parse"));
|
|
17
|
+
/**
|
|
18
|
+
* The QueryParameterDecoratorResolver resolves the value of the query parameter with the name passed to the decorator
|
|
19
|
+
* of the request so that it can be injected it into the parameter of the route of the controller that was annotated
|
|
20
|
+
* with the @queryParameter decorator.
|
|
21
|
+
* It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
|
|
22
|
+
*/
|
|
17
23
|
let QueryParameterDecoratorResolver = class QueryParameterDecoratorResolver {
|
|
24
|
+
/**
|
|
25
|
+
* Resolves the value of the query parameter with the specified name of the request.
|
|
26
|
+
* The router than injects that value into the parameter of the controller method.
|
|
27
|
+
* @param methodArgument The method argument created by the decorator including the query parameter name.
|
|
28
|
+
* @param request The request
|
|
29
|
+
* @param routeParameters The router parameters
|
|
30
|
+
* @param identity The identity making the request
|
|
31
|
+
*/
|
|
18
32
|
resolve(methodArgument, request, routeParameters, identity) {
|
|
19
33
|
var _a;
|
|
20
34
|
const url = new url_parse_1.default(request.url, true);
|
|
21
35
|
return Promise.resolve((_a = url.query[methodArgument.queryParameterName]) !== null && _a !== void 0 ? _a : null);
|
|
22
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Returns whether or not the resolver support such a method argument.
|
|
39
|
+
* Usually we will check the methodArgument.type field to determine if it is a supported type.
|
|
40
|
+
* @param methodArgument
|
|
41
|
+
*/
|
|
23
42
|
supports(methodArgument) {
|
|
24
43
|
return methodArgument && methodArgument.hasOwnProperty("type") && methodArgument.type === "queryParameter";
|
|
25
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-parameter-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/query-parameter-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAoC;
|
|
1
|
+
{"version":3,"file":"query-parameter-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/query-parameter-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAoC;AAGpC,gDAAmG;AACnG,4EAAqE;AACrE,0DAA4B;AAI5B;;;;;GAKG;AAIH,IAAa,+BAA+B,GAA5C,MAAa,+BAA+B;IAExC;;;;;;;OAOG;IACH,OAAO,CAAC,cAAgD,EAChD,OAAgB,EAChB,eAAwC,EACxC,QAA4B;;QAChC,MAAM,GAAG,GAAG,IAAI,mBAAG,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAEvC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAA,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,kBAAkB,CAAC,mCAAI,IAAI,CAAC,CAAC;IACjF,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,cAA2C;QAChD,OAAO,cAAc,IAAI,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,KAAK,gBAAgB,CAAC;IAC/G,CAAC;CACJ,CAAA;AA3BY,+BAA+B;IAH3C,qBAAY,CAAC,mDAAuB,CAAC;IACrC,YAAG,CAAC,iCAAwB,CAAC,gCAAgC,CAAC;IAC9D,qBAAU,EAAE;GACA,+BAA+B,CA2B3C;AA3BY,0EAA+B"}
|
|
@@ -14,12 +14,30 @@ const tsyringe_1 = require("tsyringe");
|
|
|
14
14
|
const common_1 = require("@pristine-ts/common");
|
|
15
15
|
const networking_module_keyname_1 = require("../networking.module.keyname");
|
|
16
16
|
const url_parse_1 = __importDefault(require("url-parse"));
|
|
17
|
+
/**
|
|
18
|
+
* The QueryParametersDecoratorResolver resolves the value (a map) of the query parameters of the request so that it can be injected it into the
|
|
19
|
+
* parameter of the route of the controller that was annotated with the @queryParameters decorator.
|
|
20
|
+
* It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
|
|
21
|
+
*/
|
|
17
22
|
let QueryParametersDecoratorResolver = class QueryParametersDecoratorResolver {
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the value of all the query parameters of the request.
|
|
25
|
+
* The router than injects that value into the parameter of the controller method.
|
|
26
|
+
* @param methodArgument The method argument created by the decorator.
|
|
27
|
+
* @param request The request
|
|
28
|
+
* @param routeParameters The router parameters
|
|
29
|
+
* @param identity The identity making the request
|
|
30
|
+
*/
|
|
18
31
|
resolve(methodArgument, request, routeParameters, identity) {
|
|
19
32
|
var _a;
|
|
20
33
|
const url = new url_parse_1.default(request.url, true);
|
|
21
34
|
return Promise.resolve((_a = url.query) !== null && _a !== void 0 ? _a : null);
|
|
22
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns whether or not the resolver support such a method argument.
|
|
38
|
+
* Usually we will check the methodArgument.type field to determine if it is a supported type.
|
|
39
|
+
* @param methodArgument
|
|
40
|
+
*/
|
|
23
41
|
supports(methodArgument) {
|
|
24
42
|
return methodArgument && methodArgument.hasOwnProperty("type") && methodArgument.type === "queryParameters";
|
|
25
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-parameters-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/query-parameters-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAoC;AAGpC,gDAAmG;AACnG,4EAAqE;AACrE,0DAA4B;
|
|
1
|
+
{"version":3,"file":"query-parameters-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/query-parameters-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAoC;AAGpC,gDAAmG;AACnG,4EAAqE;AACrE,0DAA4B;AAI5B;;;;GAIG;AAIH,IAAa,gCAAgC,GAA7C,MAAa,gCAAgC;IAEzC;;;;;;;OAOG;IACH,OAAO,CAAC,cAAiD,EACjD,OAAgB,EAChB,eAAwC,EACxC,QAA4B;;QAChC,MAAM,GAAG,GAAG,IAAI,mBAAG,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAEvC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAA,GAAG,CAAC,KAAK,mCAAI,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,cAA2C;QAChD,OAAO,cAAc,IAAI,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,KAAK,iBAAiB,CAAC;IAChH,CAAC;CACJ,CAAA;AA3BY,gCAAgC;IAH5C,qBAAY,CAAC,mDAAuB,CAAC;IACrC,YAAG,CAAC,iCAAwB,CAAC,gCAAgC,CAAC;IAC9D,qBAAU,EAAE;GACA,gCAAgC,CA2B5C;AA3BY,4EAAgC"}
|
|
@@ -10,11 +10,29 @@ exports.RouteParameterDecoratorResolver = void 0;
|
|
|
10
10
|
const tsyringe_1 = require("tsyringe");
|
|
11
11
|
const common_1 = require("@pristine-ts/common");
|
|
12
12
|
const networking_module_keyname_1 = require("../networking.module.keyname");
|
|
13
|
+
/**
|
|
14
|
+
* The RouteParameterDecoratorResolver resolves the value of the route parameter specified of the request so that it can be injected it into the
|
|
15
|
+
* parameter of the route of the controller that was annotated with the @routeParameter decorator.
|
|
16
|
+
* It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
|
|
17
|
+
*/
|
|
13
18
|
let RouteParameterDecoratorResolver = class RouteParameterDecoratorResolver {
|
|
19
|
+
/**
|
|
20
|
+
* Resolves the value of the the route parameter with the specified name of the request.
|
|
21
|
+
* The router than injects that value into the parameter of the controller method.
|
|
22
|
+
* @param methodArgument The method argument created by the decorator, including the name of the parameter to resolve.
|
|
23
|
+
* @param request The request
|
|
24
|
+
* @param routeParameters The router parameters
|
|
25
|
+
* @param identity The identity making the request
|
|
26
|
+
*/
|
|
14
27
|
resolve(methodArgument, request, routeParameters, identity) {
|
|
15
28
|
var _a;
|
|
16
29
|
return Promise.resolve((_a = routeParameters[methodArgument.routeParameterName]) !== null && _a !== void 0 ? _a : null);
|
|
17
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns whether or not the resolver support such a method argument.
|
|
33
|
+
* Usually we will check the methodArgument.type field to determine if it is a supported type.
|
|
34
|
+
* @param methodArgument
|
|
35
|
+
*/
|
|
18
36
|
supports(methodArgument) {
|
|
19
37
|
return methodArgument && methodArgument.hasOwnProperty("type") && methodArgument.type === "routeParameter";
|
|
20
38
|
}
|