@pristine-ts/networking 0.0.162 → 0.0.166
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/request-parameter-decorator.resolver.js +18 -0
- package/dist/lib/cjs/resolvers/request-parameter-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 +25 -10
- 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/request-parameter-decorator.resolver.js +18 -0
- package/dist/lib/esm/resolvers/request-parameter-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 +25 -10
- 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/request-parameter-decorator.resolver.d.ts +22 -2
- package/dist/types/resolvers/route-parameter-decorator.resolver.d.ts +22 -2
- package/dist/types/router.d.ts +13 -3
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-parameter-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/request-parameter-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4BAAyB;AACzB,uCAAoC;AAGpC,gDAAmG;AACnG,4EAAqE;
|
|
1
|
+
{"version":3,"file":"request-parameter-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/request-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,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAI,CAAC,CAAC;IAC5C,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"}
|
|
@@ -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
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-parameter-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/route-parameter-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAoC;AAGpC,gDAAmG;AACnG,4EAAqE;
|
|
1
|
+
{"version":3,"file":"route-parameter-decorator.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/route-parameter-decorator.resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAoC;AAGpC,gDAAmG;AACnG,4EAAqE;AAGrE;;;;GAIG;AAIH,IAAa,+BAA+B,GAA5C,MAAa,+BAA+B;IAExC;;;;;;;OAOG;IACH,OAAO,CAAC,cAAgD,EAChD,OAAgB,EAChB,eAAwC,EACxC,QAA4B;;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAA,eAAe,CAAC,cAAc,CAAC,kBAAkB,CAAC,mCAAI,IAAI,CAAC,CAAC;IACvF,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;AAzBY,+BAA+B;IAH3C,qBAAY,CAAC,mDAAuB,CAAC;IACrC,YAAG,CAAC,iCAAwB,CAAC,gCAAgC,CAAC;IAC9D,qBAAU,EAAE;GACA,+BAA+B,CAyB3C;AAzBY,0EAA+B"}
|
package/dist/lib/cjs/router.js
CHANGED
|
@@ -36,13 +36,24 @@ const url_parse_1 = __importDefault(require("url-parse"));
|
|
|
36
36
|
const common_1 = require("@pristine-ts/common");
|
|
37
37
|
const networking_module_keyname_1 = require("./networking.module.keyname");
|
|
38
38
|
const telemetry_1 = require("@pristine-ts/telemetry");
|
|
39
|
+
/**
|
|
40
|
+
* The router service is the service that creates the routing tree from the controllers.
|
|
41
|
+
* It also executes a request properly by routing it to the intended controller and returns the response.
|
|
42
|
+
*/
|
|
39
43
|
let Router = class Router {
|
|
40
|
-
|
|
44
|
+
/**
|
|
45
|
+
* The router service is the service that creates the routing tree from the controllers.
|
|
46
|
+
* It also executes a request properly by routing it to the intended controller and returns the response.
|
|
47
|
+
* @param loghandler The log handler
|
|
48
|
+
* @param controllerMethodParameterDecoratorResolver The controller method parameter decorator resolver used to resolve the values.
|
|
49
|
+
* @param authorizerManager The authorizer manager to validate authorization.
|
|
50
|
+
* @param authenticationManager The authentication manager to validate authentication.
|
|
51
|
+
*/
|
|
52
|
+
constructor(loghandler, controllerMethodParameterDecoratorResolver, authorizerManager, authenticationManager) {
|
|
41
53
|
this.loghandler = loghandler;
|
|
42
54
|
this.controllerMethodParameterDecoratorResolver = controllerMethodParameterDecoratorResolver;
|
|
43
55
|
this.authorizerManager = authorizerManager;
|
|
44
56
|
this.authenticationManager = authenticationManager;
|
|
45
|
-
this.tracingManager = tracingManager;
|
|
46
57
|
this.root = new path_router_node_1.PathRouterNode("/");
|
|
47
58
|
}
|
|
48
59
|
/**
|
|
@@ -65,13 +76,14 @@ let Router = class Router {
|
|
|
65
76
|
* @param container
|
|
66
77
|
*/
|
|
67
78
|
execute(request, container) {
|
|
68
|
-
const
|
|
79
|
+
const tracingManager = container.resolve("TracingManagerInterface");
|
|
80
|
+
const routerRequestExecutionSpan = tracingManager.startSpan(telemetry_1.SpanKeynameEnum.RouterRequestExecution, telemetry_1.SpanKeynameEnum.RequestExecution);
|
|
69
81
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
70
82
|
// Start by decomposing the URL. Set second parameter to true since we want to parse the query strings
|
|
71
83
|
const url = new url_parse_1.default(request.url, false);
|
|
72
84
|
// Split the path name
|
|
73
85
|
const splitPath = url_util_1.UrlUtil.splitPath(url.pathname);
|
|
74
|
-
const methodNodeSpan =
|
|
86
|
+
const methodNodeSpan = tracingManager.startSpan(telemetry_1.SpanKeynameEnum.RouterFindMethodRouterNode, telemetry_1.SpanKeynameEnum.RouterRequestExecution);
|
|
75
87
|
// Retrieve the node to have information about the controller
|
|
76
88
|
const methodNode = this.root.find(splitPath, request.httpMethod);
|
|
77
89
|
methodNodeSpan.end();
|
|
@@ -94,7 +106,7 @@ let Router = class Router {
|
|
|
94
106
|
// Get the route parameters
|
|
95
107
|
const routeParameters = methodNode.parent.getRouteParameters(splitPath.reverse());
|
|
96
108
|
// Instantiate the controller
|
|
97
|
-
const routerControllerResolverSpan =
|
|
109
|
+
const routerControllerResolverSpan = tracingManager.startSpan(telemetry_1.SpanKeynameEnum.RouterControllerResolver, telemetry_1.SpanKeynameEnum.RouterRequestExecution);
|
|
98
110
|
const controller = container.resolve(methodNode.route.controllerInstantiationToken);
|
|
99
111
|
routerControllerResolverSpan.end();
|
|
100
112
|
this.loghandler.debug("Before calling the authenticationManager", {
|
|
@@ -102,8 +114,9 @@ let Router = class Router {
|
|
|
102
114
|
routeParameters
|
|
103
115
|
}, networking_module_keyname_1.NetworkingModuleKeyname);
|
|
104
116
|
let identity;
|
|
117
|
+
// Authenticate the request
|
|
105
118
|
try {
|
|
106
|
-
const routerRequestAuthenticationSpan =
|
|
119
|
+
const routerRequestAuthenticationSpan = tracingManager.startSpan(telemetry_1.SpanKeynameEnum.RouterRequestAuthentication, telemetry_1.SpanKeynameEnum.RouterRequestExecution);
|
|
107
120
|
identity = yield this.authenticationManager.authenticate(request, methodNode.route.context, container);
|
|
108
121
|
routerRequestAuthenticationSpan.end();
|
|
109
122
|
this.loghandler.debug("Found identity.", {
|
|
@@ -126,6 +139,7 @@ let Router = class Router {
|
|
|
126
139
|
}
|
|
127
140
|
// Call the controller with the resolved Method arguments
|
|
128
141
|
try {
|
|
142
|
+
// Verify that the identity making the request is authorized to make such a request
|
|
129
143
|
if ((yield this.authorizerManager.isAuthorized(request, methodNode.route.context, container, identity)) === false) {
|
|
130
144
|
this.loghandler.error("User not authorized to access this url.", {
|
|
131
145
|
request,
|
|
@@ -136,13 +150,15 @@ let Router = class Router {
|
|
|
136
150
|
routerRequestExecutionSpan.end();
|
|
137
151
|
return reject(new forbidden_http_error_1.ForbiddenHttpError("You are not allowed to access this."));
|
|
138
152
|
}
|
|
139
|
-
|
|
153
|
+
// Execute all the enrichers to enrich the request.
|
|
154
|
+
const requestEnrichersSpan = tracingManager.startSpan(telemetry_1.SpanKeynameEnum.RouterRequestEnrichers, telemetry_1.SpanKeynameEnum.RouterRequestExecution);
|
|
140
155
|
const enrichedRequest = yield this.executeRequestEnrichers(request, container, methodNode);
|
|
141
156
|
requestEnrichersSpan.end();
|
|
142
157
|
this.loghandler.debug("This request has been enriched", {
|
|
143
158
|
request,
|
|
144
159
|
enrichedRequest,
|
|
145
160
|
}, networking_module_keyname_1.NetworkingModuleKeyname);
|
|
161
|
+
// Resolve the value to inject in the method arguments that have a decorator resolver
|
|
146
162
|
const resolvedMethodArguments = [];
|
|
147
163
|
for (const methodArgument of methodNode.route.methodArguments) {
|
|
148
164
|
resolvedMethodArguments.push(yield this.controllerMethodParameterDecoratorResolver.resolve(methodArgument, enrichedRequest, routeParameters, identity));
|
|
@@ -169,7 +185,7 @@ let Router = class Router {
|
|
|
169
185
|
returnedResponse.status = 200;
|
|
170
186
|
returnedResponse.body = response;
|
|
171
187
|
}
|
|
172
|
-
const responseEnrichersSpan =
|
|
188
|
+
const responseEnrichersSpan = tracingManager.startSpan(telemetry_1.SpanKeynameEnum.RouterResponseEnrichers, telemetry_1.SpanKeynameEnum.RouterRequestExecution);
|
|
173
189
|
const enrichedResponse = yield this.executeResponseEnrichers(returnedResponse, request, container, methodNode);
|
|
174
190
|
responseEnrichersSpan.end();
|
|
175
191
|
this.loghandler.debug("This response has been enriched", {
|
|
@@ -265,8 +281,7 @@ Router = __decorate([
|
|
|
265
281
|
__param(0, tsyringe_1.inject("LogHandlerInterface")),
|
|
266
282
|
__param(2, tsyringe_1.inject("AuthorizerManagerInterface")),
|
|
267
283
|
__param(3, tsyringe_1.inject("AuthenticationManagerInterface")),
|
|
268
|
-
|
|
269
|
-
__metadata("design:paramtypes", [Object, controller_method_parameter_decorator_resolver_1.ControllerMethodParameterDecoratorResolver, Object, Object, Object])
|
|
284
|
+
__metadata("design:paramtypes", [Object, controller_method_parameter_decorator_resolver_1.ControllerMethodParameterDecoratorResolver, Object, Object])
|
|
270
285
|
], Router);
|
|
271
286
|
exports.Router = Router;
|
|
272
287
|
//# sourceMappingURL=router.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../src/router.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAgE;AAEhE,gDAA2C;AAC3C,+CAAyC;AACzC,wEAAgE;AAGhE,+DAAwD;AAGxD,wEAAiE;AACjE,+HAAsH;AACtH,0DAA4B;AAC5B,gDAA4F;AAK5F,2EAAoE;AACpE,sDAAsF;
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../src/router.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAgE;AAEhE,gDAA2C;AAC3C,+CAAyC;AACzC,wEAAg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Q,IAAI,SAAS,EAAE;oBAC9B,+HAA+H;oBAC/H,2EAA2E;oBAC3E,IAAI,OAAO,QAAQ,CAAC,aAAa,KAAK,WAAW,EAAE;wBAC/C,kCAAkC;wBAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,GAAG,yHAAyH,CAAC,CAAA;qBAClN;oBAED,IAAI;wBACA,8CAA8C;wBAC9C,eAAe,GAAG,MAAM,OAAO,CAAC,OAAO,CAAE,QAA2C,CAAC,aAAa,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC;qBACpI;oBAAC,OAAO,CAAC,EAAE;wBACR,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,kHAAkH,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,GAAG,IAAI,EAAE,EAAC,CAAC,EAAC,EAAE,mDAAuB,CAAC,CAAC;wBAC3M,MAAM,CAAC,CAAC;qBACX;iBACJ;aACJ;YAED,OAAO,eAAe,CAAC;QAC3B,CAAC;KAAA;CACJ,CAAA;AA/QY,MAAM;IADlB,oBAAS,EAAE;IAYa,WAAA,iBAAM,CAAC,qBAAqB,CAAC,CAAA;IAE7B,WAAA,iBAAM,CAAC,4BAA4B,CAAC,CAAA;IACpC,WAAA,iBAAM,CAAC,gCAAgC,CAAC,CAAA;6CAFoB,2FAA0C;GAZlH,MAAM,CA+QlB;AA/QY,wBAAM"}
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The body decorator can be used to inject the body of a request in a parameter of a method in a controller.
|
|
3
|
+
*/
|
|
1
4
|
export const body = () => {
|
|
2
|
-
return (
|
|
5
|
+
return (
|
|
6
|
+
/**
|
|
7
|
+
* The class on which the decorator is used.
|
|
8
|
+
*/
|
|
9
|
+
target,
|
|
10
|
+
/**
|
|
11
|
+
* The method on which the decorator is used.
|
|
12
|
+
*/
|
|
13
|
+
propertyKey,
|
|
14
|
+
/**
|
|
15
|
+
* The index of the parameter for which the decorator is used.
|
|
16
|
+
*/
|
|
17
|
+
parameterIndex) => {
|
|
18
|
+
// Verify that the object target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"] exists or we create it.
|
|
19
|
+
// This object is a convention defined by Pristine on where to save controller method parameter decorator information and is used in the router to retrieve that information.
|
|
3
20
|
if (target.constructor.prototype.hasOwnProperty("__metadata__") === false) {
|
|
4
21
|
target.constructor.prototype["__metadata__"] = {};
|
|
5
22
|
}
|
|
@@ -12,9 +29,11 @@ export const body = () => {
|
|
|
12
29
|
if (target.constructor.prototype["__metadata__"]["methods"][propertyKey].hasOwnProperty("arguments") === false) {
|
|
13
30
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"] = [];
|
|
14
31
|
}
|
|
32
|
+
// Set the type of method parameter. Each parameter decorator has it's own type.
|
|
15
33
|
const methodParameter = {
|
|
16
34
|
type: "body"
|
|
17
35
|
};
|
|
36
|
+
// Save the method parameter with the proper parameter index (index of the parameter in the list of parameters of a method).
|
|
18
37
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"][parameterIndex] = methodParameter;
|
|
19
38
|
};
|
|
20
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/body.decorator.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE;IACrB,OAAO,
|
|
1
|
+
{"version":3,"file":"body.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/body.decorator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE;IACrB,OAAO;IACH;;OAEG;IACH,MAAc;IAEd;;OAEG;IACH,WAA4B;IAE5B;;OAEG;IACH,cAAsB,EACxB,EAAE;QACA,mIAAmI;QACnI,6KAA6K;QAC7K,IAAI,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,KAAK,EAAE;YACvE,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,CAAA;SACpD;QAED,IAAI,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,KAAK,EAAE;YAClF,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAA;SAC/D;QAED,IAAI,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,KAAK,EAAE;YAC/F,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAA;SAC5E;QAED,IAAI,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,KAAK,EAAE;YAC5G,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;SAC1F;QAED,gFAAgF;QAChF,MAAM,eAAe,GAAoC;YACrD,IAAI,EAAE,MAAM;SACf,CAAC;QAEF,4HAA4H;QAC5H,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,GAAG,eAAe,CAAC;IACxH,CAAC,CAAA;AACL,CAAC,CAAC"}
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
export const controllerRegistry = [];
|
|
2
|
+
/**
|
|
3
|
+
* The controller decorator can be used on a class to register this class as a controller in the router.
|
|
4
|
+
* @param basePath The base path for all the routes in the controller.
|
|
5
|
+
*/
|
|
2
6
|
export const controller = (basePath) => {
|
|
3
|
-
return (
|
|
7
|
+
return (
|
|
8
|
+
/**
|
|
9
|
+
* The constructor of the class
|
|
10
|
+
*/
|
|
11
|
+
constructor) => {
|
|
12
|
+
// Verify that the object constructor.prototype["__metadata__"]["controller"][basePath] exists or we create it.
|
|
13
|
+
// This object is a convention defined by Pristine on where to save controller decorator information and is used in the router to retrieve that information.
|
|
4
14
|
if (constructor.prototype.hasOwnProperty("__metadata__") === false) {
|
|
5
15
|
constructor.prototype["__metadata__"] = {};
|
|
6
16
|
}
|
|
7
17
|
if (constructor.prototype["__metadata__"].hasOwnProperty("controller") === false) {
|
|
8
18
|
constructor.prototype["__metadata__"]["controller"] = {};
|
|
9
19
|
}
|
|
20
|
+
// Save the base path.
|
|
10
21
|
constructor.prototype["__metadata__"]["controller"]["basePath"] = basePath;
|
|
22
|
+
// Push the class prototype in the controllerRegistry that is used to instantiate all the controllers for the router.
|
|
11
23
|
controllerRegistry.push(constructor.prototype);
|
|
12
24
|
};
|
|
13
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/controller.decorator.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAU,EAAE,CAAC;AAE5C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"controller.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/controller.decorator.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAU,EAAE,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC3C,OAAO;IACH;;OAEG;IACH,WAAqB,EACvB,EAAE;QACA,+GAA+G;QAC/G,4JAA4J;QAC5J,IAAG,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,KAAK,EAAE;YAC/D,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,CAAA;SAC7C;QAGD,IAAG,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,YAAY,CAAC,KAAK,KAAK,EAAE;YAC7E,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC,GAAG,EAAE,CAAA;SAC3D;QAED,sBAAsB;QACtB,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;QAE3E,qHAAqH;QACrH,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;IAClD,CAAC,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./body.decorator";
|
|
2
2
|
export * from "./controller.decorator";
|
|
3
|
-
export * from "./identity.decorator";
|
|
4
3
|
export * from "./headers.decorator";
|
|
4
|
+
export * from "./identity.decorator";
|
|
5
5
|
export * from "./query-parameter.decorator";
|
|
6
6
|
export * from "./query-parameters.decorator";
|
|
7
7
|
export * from "./request.decorator";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../src/decorators/decorators.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../src/decorators/decorators.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC"}
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The headers decorator can be used to inject the headers of a request in a parameter of a method in a controller.
|
|
3
|
+
*/
|
|
1
4
|
export const headers = () => {
|
|
2
|
-
return (
|
|
5
|
+
return (
|
|
6
|
+
/**
|
|
7
|
+
* The class on which the decorator is used.
|
|
8
|
+
*/
|
|
9
|
+
target,
|
|
10
|
+
/**
|
|
11
|
+
* The method on which the decorator is used.
|
|
12
|
+
*/
|
|
13
|
+
propertyKey,
|
|
14
|
+
/**
|
|
15
|
+
* The index of the parameter for which the decorator is used.
|
|
16
|
+
*/
|
|
17
|
+
parameterIndex) => {
|
|
18
|
+
// Verify that the object target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"] exists or we create it.
|
|
19
|
+
// This object is a convention defined by Pristine on where to save controller method parameter decorator information and is used in the router to retrieve that information.
|
|
3
20
|
if (target.constructor.prototype.hasOwnProperty("__metadata__") === false) {
|
|
4
21
|
target.constructor.prototype["__metadata__"] = {};
|
|
5
22
|
}
|
|
@@ -12,9 +29,11 @@ export const headers = () => {
|
|
|
12
29
|
if (target.constructor.prototype["__metadata__"]["methods"][propertyKey].hasOwnProperty("arguments") === false) {
|
|
13
30
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"] = [];
|
|
14
31
|
}
|
|
32
|
+
// Set the type of method parameter. Each parameter decorator has it's own type.
|
|
15
33
|
const methodParameter = {
|
|
16
34
|
type: "headers"
|
|
17
35
|
};
|
|
36
|
+
// Save the method parameter with the proper parameter index (index of the parameter in the list of parameters of a method).
|
|
18
37
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"][parameterIndex] = methodParameter;
|
|
19
38
|
};
|
|
20
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headers.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/headers.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"headers.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/headers.decorator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE;IACxB,OAAO;IACH;;OAEG;IACH,MAAc;IAEd;;OAEG;IACH,WAA4B;IAE5B;;OAEG;IACH,cAAsB,EACxB,EAAE;QACA,mIAAmI;QACnI,6KAA6K;QAC7K,IAAI,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,KAAK,EAAE;YACvE,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,CAAA;SACpD;QAED,IAAI,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,KAAK,EAAE;YAClF,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAA;SAC/D;QAED,IAAI,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,KAAK,EAAE;YAC/F,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAA;SAC5E;QAED,IAAI,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,KAAK,EAAE;YAC5G,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;SAC1F;QAED,gFAAgF;QAChF,MAAM,eAAe,GAAuC;YACxD,IAAI,EAAE,SAAS;SAClB,CAAC;QAEF,4HAA4H;QAC5H,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,GAAG,eAAe,CAAC;IACxH,CAAC,CAAA;AACL,CAAC,CAAC"}
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The identity decorator can be used to inject the identity making the request in a parameter of a method in a controller.
|
|
3
|
+
*/
|
|
1
4
|
export const identity = () => {
|
|
2
|
-
return (
|
|
5
|
+
return (
|
|
6
|
+
/**
|
|
7
|
+
* The class on which the decorator is used.
|
|
8
|
+
*/
|
|
9
|
+
target,
|
|
10
|
+
/**
|
|
11
|
+
* The method on which the decorator is used.
|
|
12
|
+
*/
|
|
13
|
+
propertyKey,
|
|
14
|
+
/**
|
|
15
|
+
* The index of the parameter for which the decorator is used.
|
|
16
|
+
*/
|
|
17
|
+
parameterIndex) => {
|
|
18
|
+
// Verify that the object target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"] exists or we create it.
|
|
19
|
+
// This object is a convention defined by Pristine on where to save controller method parameter decorator information and is used in the router to retrieve that information.
|
|
3
20
|
if (target.constructor.prototype.hasOwnProperty("__metadata__") === false) {
|
|
4
21
|
target.constructor.prototype["__metadata__"] = {};
|
|
5
22
|
}
|
|
@@ -12,9 +29,11 @@ export const identity = () => {
|
|
|
12
29
|
if (target.constructor.prototype["__metadata__"]["methods"][propertyKey].hasOwnProperty("arguments") === false) {
|
|
13
30
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"] = [];
|
|
14
31
|
}
|
|
32
|
+
// Set the type of method parameter. Each parameter decorator has it's own type.
|
|
15
33
|
const methodParameter = {
|
|
16
34
|
type: "identity"
|
|
17
35
|
};
|
|
36
|
+
// Save the method parameter with the proper parameter index (index of the parameter in the list of parameters of a method).
|
|
18
37
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"][parameterIndex] = methodParameter;
|
|
19
38
|
};
|
|
20
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/identity.decorator.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IACzB,OAAO,
|
|
1
|
+
{"version":3,"file":"identity.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/identity.decorator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IACzB,OAAO;IACH;;OAEG;IACH,MAAc;IAEd;;OAEG;IACH,WAA4B;IAE5B;;OAEG;IACH,cAAsB,EACxB,EAAE;QACA,mIAAmI;QACnI,6KAA6K;QAC7K,IAAI,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,KAAK,EAAE;YACvE,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,CAAA;SACpD;QAED,IAAI,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,KAAK,EAAE;YAClF,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAA;SAC/D;QAED,IAAI,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,KAAK,EAAE;YAC/F,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAA;SAC5E;QAED,IAAI,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,KAAK,EAAE;YAC5G,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;SAC1F;QAED,gFAAgF;QAChF,MAAM,eAAe,GAAwC;YACzD,IAAI,EAAE,UAAU;SACnB,CAAC;QAEF,4HAA4H;QAC5H,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,GAAG,eAAe,CAAC;IACxH,CAAC,CAAA;AACL,CAAC,CAAC"}
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The queryParameter decorator can be used to inject a specific query parameter of a request in a parameter of a method in a controller.
|
|
3
|
+
* @param name The name of the query parameter to inject.
|
|
4
|
+
*/
|
|
1
5
|
export const queryParameter = (name) => {
|
|
2
|
-
return (
|
|
6
|
+
return (
|
|
7
|
+
/**
|
|
8
|
+
* The class on which the decorator is used.
|
|
9
|
+
*/
|
|
10
|
+
target,
|
|
11
|
+
/**
|
|
12
|
+
* The method on which the decorator is used.
|
|
13
|
+
*/
|
|
14
|
+
propertyKey,
|
|
15
|
+
/**
|
|
16
|
+
* The index of the parameter for which the decorator is used.
|
|
17
|
+
*/
|
|
18
|
+
parameterIndex) => {
|
|
19
|
+
// Verify that the object target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"] exists or we create it.
|
|
20
|
+
// This object is a convention defined by Pristine on where to save controller method parameter decorator information and is used in the router to retrieve that information.
|
|
3
21
|
if (target.constructor.prototype.hasOwnProperty("__metadata__") === false) {
|
|
4
22
|
target.constructor.prototype["__metadata__"] = {};
|
|
5
23
|
}
|
|
@@ -12,10 +30,13 @@ export const queryParameter = (name) => {
|
|
|
12
30
|
if (target.constructor.prototype["__metadata__"]["methods"][propertyKey].hasOwnProperty("arguments") === false) {
|
|
13
31
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"] = [];
|
|
14
32
|
}
|
|
33
|
+
// Set the type of method parameter. Each parameter decorator has it's own type.
|
|
34
|
+
// Set also the name of the query parameter to resolve.
|
|
15
35
|
const methodParameter = {
|
|
16
36
|
type: "queryParameter",
|
|
17
37
|
queryParameterName: name,
|
|
18
38
|
};
|
|
39
|
+
// Save the method parameter with the proper parameter index (index of the parameter in the list of parameters of a method).
|
|
19
40
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"][parameterIndex] = methodParameter;
|
|
20
41
|
};
|
|
21
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-parameter.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/query-parameter.decorator.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,EAAE;IAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"query-parameter.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/query-parameter.decorator.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,EAAE;IAC3C,OAAO;IACH;;OAEG;IACH,MAAc;IAEd;;OAEG;IACH,WAA4B;IAE5B;;OAEG;IACH,cAAsB,EACxB,EAAE;QACA,mIAAmI;QACnI,6KAA6K;QAC7K,IAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,KAAK,EAAE;YACtE,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,CAAA;SACpD;QAED,IAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,KAAK,EAAE;YACjF,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAA;SAC/D;QAED,IAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,KAAK,EAAE;YAC9F,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAA;SAC5E;QAED,IAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,KAAK,EAAE;YAC3G,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;SAC1F;QAED,gFAAgF;QAChF,uDAAuD;QACvD,MAAM,eAAe,GAAqC;YACtD,IAAI,EAAE,gBAAgB;YACtB,kBAAkB,EAAE,IAAI;SAC3B,CAAC;QAEF,4HAA4H;QAC5H,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,GAAG,eAAe,CAAC;IACxH,CAAC,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The queryParameters decorator can be used to inject all the query parameters of a request in a parameter of a method in a controller.
|
|
3
|
+
*/
|
|
1
4
|
export const queryParameters = () => {
|
|
2
|
-
return (
|
|
5
|
+
return (
|
|
6
|
+
/**
|
|
7
|
+
* The class on which the decorator is used.
|
|
8
|
+
*/
|
|
9
|
+
target,
|
|
10
|
+
/**
|
|
11
|
+
* The method on which the decorator is used.
|
|
12
|
+
*/
|
|
13
|
+
propertyKey,
|
|
14
|
+
/**
|
|
15
|
+
* The index of the parameter for which the decorator is used.
|
|
16
|
+
*/
|
|
17
|
+
parameterIndex) => {
|
|
18
|
+
// Verify that the object target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"] exists or we create it.
|
|
19
|
+
// This object is a convention defined by Pristine on where to save controller method parameter decorator information and is used in the router to retrieve that information.
|
|
3
20
|
if (target.constructor.prototype.hasOwnProperty("__metadata__") === false) {
|
|
4
21
|
target.constructor.prototype["__metadata__"] = {};
|
|
5
22
|
}
|
|
@@ -12,9 +29,11 @@ export const queryParameters = () => {
|
|
|
12
29
|
if (target.constructor.prototype["__metadata__"]["methods"][propertyKey].hasOwnProperty("arguments") === false) {
|
|
13
30
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"] = [];
|
|
14
31
|
}
|
|
32
|
+
// Set the type of method parameter. Each parameter decorator has it's own type.
|
|
15
33
|
const methodParameter = {
|
|
16
34
|
type: "queryParameters",
|
|
17
35
|
};
|
|
36
|
+
// Save the method parameter with the proper parameter index (index of the parameter in the list of parameters of a method).
|
|
18
37
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"][parameterIndex] = methodParameter;
|
|
19
38
|
};
|
|
20
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-parameters.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/query-parameters.decorator.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAChC,OAAO,
|
|
1
|
+
{"version":3,"file":"query-parameters.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/query-parameters.decorator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAChC,OAAO;IACH;;OAEG;IACH,MAAc;IAEd;;OAEG;IACH,WAA4B;IAE5B;;OAEG;IACH,cAAsB,EACxB,EAAE;QACA,mIAAmI;QACnI,6KAA6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ator can be used to inject the whole request in a parameter of a method in a controller.
|
|
3
|
+
*/
|
|
1
4
|
export const request = () => {
|
|
2
|
-
return (
|
|
5
|
+
return (
|
|
6
|
+
/**
|
|
7
|
+
* The class on which the decorator is used.
|
|
8
|
+
*/
|
|
9
|
+
target,
|
|
10
|
+
/**
|
|
11
|
+
* The method on which the decorator is used.
|
|
12
|
+
*/
|
|
13
|
+
propertyKey,
|
|
14
|
+
/**
|
|
15
|
+
* The index of the parameter for which the decorator is used.
|
|
16
|
+
*/
|
|
17
|
+
parameterIndex) => {
|
|
18
|
+
// Verify that the object target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"] exists or we create it.
|
|
19
|
+
// This object is a convention defined by Pristine on where to save controller method parameter decorator information and is used in the router to retrieve that information.
|
|
3
20
|
if (target.constructor.prototype.hasOwnProperty("__metadata__") === false) {
|
|
4
21
|
target.constructor.prototype["__metadata__"] = {};
|
|
5
22
|
}
|
|
@@ -12,9 +29,11 @@ export const request = () => {
|
|
|
12
29
|
if (target.constructor.prototype["__metadata__"]["methods"][propertyKey].hasOwnProperty("arguments") === false) {
|
|
13
30
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"] = [];
|
|
14
31
|
}
|
|
32
|
+
// Set the type of method parameter. Each parameter decorator has it's own type.
|
|
15
33
|
const methodParameter = {
|
|
16
34
|
type: "request"
|
|
17
35
|
};
|
|
36
|
+
// Save the method parameter with the proper parameter index (index of the parameter in the list of parameters of a method).
|
|
18
37
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"][parameterIndex] = methodParameter;
|
|
19
38
|
};
|
|
20
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/request.decorator.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE;IACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"request.decorator.js","sourceRoot":"","sources":["../../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AC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,GAAG,eAAe,CAAC;IACxH,CAAC,CAAA;AACL,CAAC,CAAC"}
|
|
@@ -1,7 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The responseHeader decorator can be used to specify a header that needs to be added to the response before sending it back.
|
|
3
|
+
* This decorator can be used with either method (route) or a class (controller).
|
|
4
|
+
* If used on the class than it will be applied to every route of the controller.
|
|
5
|
+
* @param key The key of the header
|
|
6
|
+
* @param value The value to set the header to.
|
|
7
|
+
*/
|
|
1
8
|
export const responseHeader = (key, value) => {
|
|
2
|
-
return (
|
|
3
|
-
|
|
9
|
+
return (
|
|
10
|
+
/**
|
|
11
|
+
* The class on which the decorator is used.
|
|
12
|
+
*/
|
|
13
|
+
target,
|
|
14
|
+
/**
|
|
15
|
+
* The method on which the decorator is used.
|
|
16
|
+
*/
|
|
17
|
+
propertyKey,
|
|
18
|
+
/**
|
|
19
|
+
* The descriptor of the property
|
|
20
|
+
*/
|
|
21
|
+
descriptor) => {
|
|
22
|
+
// If there's a descriptor and a property key, then it's not a controller decorator, but a method decorator
|
|
4
23
|
if (descriptor && propertyKey) {
|
|
24
|
+
// Verify that the object target.constructor.prototype["__metadata__"]["methods"][propertyKey]["__routeContext__"]["responseHeaders"] exists or we create it.
|
|
25
|
+
// This object is a convention defined by Pristine on where to save controller method parameter decorator information and is used in the router to retrieve that information.
|
|
5
26
|
if (target.constructor.prototype.hasOwnProperty("__metadata__") === false) {
|
|
6
27
|
target.constructor.prototype["__metadata__"] = {};
|
|
7
28
|
}
|
|
@@ -20,6 +41,7 @@ export const responseHeader = (key, value) => {
|
|
|
20
41
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["__routeContext__"]["responseHeaders"][key] = value;
|
|
21
42
|
}
|
|
22
43
|
else {
|
|
44
|
+
// It is a controller decorator
|
|
23
45
|
if (target.prototype.hasOwnProperty("__metadata__") === false) {
|
|
24
46
|
target.prototype["__metadata__"] = {};
|
|
25
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-header.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/response-header.decorator.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,EAAE;IACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"response-header.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/response-header.decorator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,EAAE;IACzD,OAAO;IACH;;OAEG;IACH,MAAW;IAEX;;OAEG;IACH,WAAoB;IAEpB;;OAEG;IACH,UAA+B,EACjC,EAAE;QAEA,2GAA2G;QAC3G,IAAG,UAAU,IAAI,WAAW,EAAE;YAC1B,6JAA6J;YAC7J,6KAA6K;YAC7K,IAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,KAAK,EAAE;gBACtE,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,CAAA;aACpD;YAED,IAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,KAAK,EAAE;gBACjF,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAA;aAC/D;YAED,IAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,KAAK,EAAE;gBAC9F,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE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AC,KAAK,KAAK,EAAE;gBAC7F,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAA;aAC1E;YAED,IAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC,kBAAkB,CAAC,CAAC,cAAc,CAAC,iBAAiB,CAAC,KAAK,KAAK,EAAE;gBAC/G,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC,kBAAkB,CAAC,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAA;aAC7F;YAED,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC,kBAAkB,CAAC,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SACtG;IACL,CAAC,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The routeParameter decorator can be used to inject a specific route parameter of a request in a parameter of a method in a controller.
|
|
3
|
+
* @param name The name of the route(path) parameter to inject.
|
|
4
|
+
*/
|
|
1
5
|
export const routeParameter = (name) => {
|
|
2
|
-
return (
|
|
6
|
+
return (
|
|
7
|
+
/**
|
|
8
|
+
* The class on which the decorator is used.
|
|
9
|
+
*/
|
|
10
|
+
target,
|
|
11
|
+
/**
|
|
12
|
+
* The method on which the decorator is used.
|
|
13
|
+
*/
|
|
14
|
+
propertyKey,
|
|
15
|
+
/**
|
|
16
|
+
* The index of the parameter for which the decorator is used.
|
|
17
|
+
*/
|
|
18
|
+
parameterIndex) => {
|
|
19
|
+
// Verify that the object target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"] exists or we create it.
|
|
20
|
+
// This object is a convention defined by Pristine on where to save controller method parameter decorator information and is used in the router to retrieve that information.
|
|
3
21
|
if (target.constructor.prototype.hasOwnProperty("__metadata__") === false) {
|
|
4
22
|
target.constructor.prototype["__metadata__"] = {};
|
|
5
23
|
}
|
|
@@ -12,10 +30,12 @@ export const routeParameter = (name) => {
|
|
|
12
30
|
if (target.constructor.prototype["__metadata__"]["methods"][propertyKey].hasOwnProperty("arguments") === false) {
|
|
13
31
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"] = [];
|
|
14
32
|
}
|
|
33
|
+
// Set the type of method parameter. Each parameter decorator has it's own type.
|
|
15
34
|
const methodParameter = {
|
|
16
35
|
type: "routeParameter",
|
|
17
36
|
routeParameterName: name,
|
|
18
37
|
};
|
|
38
|
+
// Save the method parameter with the proper parameter index (index of the parameter in the list of parameters of a method).
|
|
19
39
|
target.constructor.prototype["__metadata__"]["methods"][propertyKey]["arguments"][parameterIndex] = methodParameter;
|
|
20
40
|
};
|
|
21
41
|
};
|