@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.
Files changed (186) hide show
  1. package/dist/lib/cjs/decorators/body.decorator.js +20 -1
  2. package/dist/lib/cjs/decorators/body.decorator.js.map +1 -1
  3. package/dist/lib/cjs/decorators/controller.decorator.js +13 -1
  4. package/dist/lib/cjs/decorators/controller.decorator.js.map +1 -1
  5. package/dist/lib/cjs/decorators/decorators.js +1 -1
  6. package/dist/lib/cjs/decorators/decorators.js.map +1 -1
  7. package/dist/lib/cjs/decorators/headers.decorator.js +20 -1
  8. package/dist/lib/cjs/decorators/headers.decorator.js.map +1 -1
  9. package/dist/lib/cjs/decorators/identity.decorator.js +20 -1
  10. package/dist/lib/cjs/decorators/identity.decorator.js.map +1 -1
  11. package/dist/lib/cjs/decorators/query-parameter.decorator.js +22 -1
  12. package/dist/lib/cjs/decorators/query-parameter.decorator.js.map +1 -1
  13. package/dist/lib/cjs/decorators/query-parameters.decorator.js +20 -1
  14. package/dist/lib/cjs/decorators/query-parameters.decorator.js.map +1 -1
  15. package/dist/lib/cjs/decorators/request.decorator.js +20 -1
  16. package/dist/lib/cjs/decorators/request.decorator.js.map +1 -1
  17. package/dist/lib/cjs/decorators/response-header.decorator.js +24 -2
  18. package/dist/lib/cjs/decorators/response-header.decorator.js.map +1 -1
  19. package/dist/lib/cjs/decorators/route-parameter.decorator.js +21 -1
  20. package/dist/lib/cjs/decorators/route-parameter.decorator.js.map +1 -1
  21. package/dist/lib/cjs/decorators/route.decorator.js +21 -1
  22. package/dist/lib/cjs/decorators/route.decorator.js.map +1 -1
  23. package/dist/lib/cjs/enrichers/router-response.enricher.js +4 -0
  24. package/dist/lib/cjs/enrichers/router-response.enricher.js.map +1 -1
  25. package/dist/lib/cjs/errors/errors.js +3 -1
  26. package/dist/lib/cjs/errors/errors.js.map +1 -1
  27. package/dist/lib/cjs/errors/http.error.js +1 -1
  28. package/dist/lib/cjs/errors/http.error.js.map +1 -1
  29. package/dist/lib/cjs/errors/method-router-adding.error.js +25 -0
  30. package/dist/lib/cjs/errors/method-router-adding.error.js.map +1 -0
  31. package/dist/lib/cjs/errors/path-router-adding.error.js +3 -2
  32. package/dist/lib/cjs/errors/path-router-adding.error.js.map +1 -1
  33. package/dist/lib/cjs/errors/path-router-instantiation.error.js +3 -2
  34. package/dist/lib/cjs/errors/path-router-instantiation.error.js.map +1 -1
  35. package/dist/lib/cjs/interfaces/interfaces.js +2 -2
  36. package/dist/lib/cjs/interfaces/interfaces.js.map +1 -1
  37. package/dist/lib/cjs/models/models.js +0 -1
  38. package/dist/lib/cjs/models/models.js.map +1 -1
  39. package/dist/lib/cjs/models/request.js +10 -4
  40. package/dist/lib/cjs/models/request.js.map +1 -1
  41. package/dist/lib/cjs/models/response.js +6 -0
  42. package/dist/lib/cjs/models/response.js.map +1 -1
  43. package/dist/lib/cjs/models/route.js +4 -0
  44. package/dist/lib/cjs/models/route.js.map +1 -1
  45. package/dist/lib/cjs/networking.module.js +0 -6
  46. package/dist/lib/cjs/networking.module.js.map +1 -1
  47. package/dist/lib/cjs/nodes/method-router.node.js +19 -4
  48. package/dist/lib/cjs/nodes/method-router.node.js.map +1 -1
  49. package/dist/lib/cjs/nodes/path-router.node.js +22 -12
  50. package/dist/lib/cjs/nodes/path-router.node.js.map +1 -1
  51. package/dist/lib/cjs/resolvers/body-parameter-decorator.resolver.js +18 -0
  52. package/dist/lib/cjs/resolvers/body-parameter-decorator.resolver.js.map +1 -1
  53. package/dist/lib/cjs/resolvers/controller-method-parameter-decorator.resolver.js +14 -0
  54. package/dist/lib/cjs/resolvers/controller-method-parameter-decorator.resolver.js.map +1 -1
  55. package/dist/lib/cjs/resolvers/headers-parameter-decorator.resolver.js +18 -0
  56. package/dist/lib/cjs/resolvers/headers-parameter-decorator.resolver.js.map +1 -1
  57. package/dist/lib/cjs/resolvers/identity-parameter-decorator.resolver.js +18 -0
  58. package/dist/lib/cjs/resolvers/identity-parameter-decorator.resolver.js.map +1 -1
  59. package/dist/lib/cjs/resolvers/query-parameter-decorator.resolver.js +19 -0
  60. package/dist/lib/cjs/resolvers/query-parameter-decorator.resolver.js.map +1 -1
  61. package/dist/lib/cjs/resolvers/query-parameters-decorator.resolver.js +18 -0
  62. package/dist/lib/cjs/resolvers/query-parameters-decorator.resolver.js.map +1 -1
  63. package/dist/lib/cjs/resolvers/request-parameter-decorator.resolver.js +18 -0
  64. package/dist/lib/cjs/resolvers/request-parameter-decorator.resolver.js.map +1 -1
  65. package/dist/lib/cjs/resolvers/route-parameter-decorator.resolver.js +18 -0
  66. package/dist/lib/cjs/resolvers/route-parameter-decorator.resolver.js.map +1 -1
  67. package/dist/lib/cjs/router.js +25 -10
  68. package/dist/lib/cjs/router.js.map +1 -1
  69. package/dist/lib/esm/decorators/body.decorator.js +20 -1
  70. package/dist/lib/esm/decorators/body.decorator.js.map +1 -1
  71. package/dist/lib/esm/decorators/controller.decorator.js +13 -1
  72. package/dist/lib/esm/decorators/controller.decorator.js.map +1 -1
  73. package/dist/lib/esm/decorators/decorators.js +1 -1
  74. package/dist/lib/esm/decorators/decorators.js.map +1 -1
  75. package/dist/lib/esm/decorators/headers.decorator.js +20 -1
  76. package/dist/lib/esm/decorators/headers.decorator.js.map +1 -1
  77. package/dist/lib/esm/decorators/identity.decorator.js +20 -1
  78. package/dist/lib/esm/decorators/identity.decorator.js.map +1 -1
  79. package/dist/lib/esm/decorators/query-parameter.decorator.js +22 -1
  80. package/dist/lib/esm/decorators/query-parameter.decorator.js.map +1 -1
  81. package/dist/lib/esm/decorators/query-parameters.decorator.js +20 -1
  82. package/dist/lib/esm/decorators/query-parameters.decorator.js.map +1 -1
  83. package/dist/lib/esm/decorators/request.decorator.js +20 -1
  84. package/dist/lib/esm/decorators/request.decorator.js.map +1 -1
  85. package/dist/lib/esm/decorators/response-header.decorator.js +24 -2
  86. package/dist/lib/esm/decorators/response-header.decorator.js.map +1 -1
  87. package/dist/lib/esm/decorators/route-parameter.decorator.js +21 -1
  88. package/dist/lib/esm/decorators/route-parameter.decorator.js.map +1 -1
  89. package/dist/lib/esm/decorators/route.decorator.js +21 -1
  90. package/dist/lib/esm/decorators/route.decorator.js.map +1 -1
  91. package/dist/lib/esm/enrichers/router-response.enricher.js +4 -0
  92. package/dist/lib/esm/enrichers/router-response.enricher.js.map +1 -1
  93. package/dist/lib/esm/errors/errors.js +3 -1
  94. package/dist/lib/esm/errors/errors.js.map +1 -1
  95. package/dist/lib/esm/errors/http.error.js +1 -1
  96. package/dist/lib/esm/errors/http.error.js.map +1 -1
  97. package/dist/lib/esm/errors/method-router-adding.error.js +21 -0
  98. package/dist/lib/esm/errors/method-router-adding.error.js.map +1 -0
  99. package/dist/lib/esm/errors/path-router-adding.error.js +3 -2
  100. package/dist/lib/esm/errors/path-router-adding.error.js.map +1 -1
  101. package/dist/lib/esm/errors/path-router-instantiation.error.js +3 -2
  102. package/dist/lib/esm/errors/path-router-instantiation.error.js.map +1 -1
  103. package/dist/lib/esm/interfaces/interfaces.js +2 -2
  104. package/dist/lib/esm/interfaces/interfaces.js.map +1 -1
  105. package/dist/lib/esm/models/models.js +0 -1
  106. package/dist/lib/esm/models/models.js.map +1 -1
  107. package/dist/lib/esm/models/request.js +10 -4
  108. package/dist/lib/esm/models/request.js.map +1 -1
  109. package/dist/lib/esm/models/response.js +6 -0
  110. package/dist/lib/esm/models/response.js.map +1 -1
  111. package/dist/lib/esm/models/route.js +4 -0
  112. package/dist/lib/esm/models/route.js.map +1 -1
  113. package/dist/lib/esm/networking.module.js +0 -6
  114. package/dist/lib/esm/networking.module.js.map +1 -1
  115. package/dist/lib/esm/nodes/method-router.node.js +19 -4
  116. package/dist/lib/esm/nodes/method-router.node.js.map +1 -1
  117. package/dist/lib/esm/nodes/path-router.node.js +22 -12
  118. package/dist/lib/esm/nodes/path-router.node.js.map +1 -1
  119. package/dist/lib/esm/resolvers/body-parameter-decorator.resolver.js +18 -0
  120. package/dist/lib/esm/resolvers/body-parameter-decorator.resolver.js.map +1 -1
  121. package/dist/lib/esm/resolvers/controller-method-parameter-decorator.resolver.js +14 -0
  122. package/dist/lib/esm/resolvers/controller-method-parameter-decorator.resolver.js.map +1 -1
  123. package/dist/lib/esm/resolvers/headers-parameter-decorator.resolver.js +18 -0
  124. package/dist/lib/esm/resolvers/headers-parameter-decorator.resolver.js.map +1 -1
  125. package/dist/lib/esm/resolvers/identity-parameter-decorator.resolver.js +18 -0
  126. package/dist/lib/esm/resolvers/identity-parameter-decorator.resolver.js.map +1 -1
  127. package/dist/lib/esm/resolvers/query-parameter-decorator.resolver.js +19 -0
  128. package/dist/lib/esm/resolvers/query-parameter-decorator.resolver.js.map +1 -1
  129. package/dist/lib/esm/resolvers/query-parameters-decorator.resolver.js +18 -0
  130. package/dist/lib/esm/resolvers/query-parameters-decorator.resolver.js.map +1 -1
  131. package/dist/lib/esm/resolvers/request-parameter-decorator.resolver.js +18 -0
  132. package/dist/lib/esm/resolvers/request-parameter-decorator.resolver.js.map +1 -1
  133. package/dist/lib/esm/resolvers/route-parameter-decorator.resolver.js +18 -0
  134. package/dist/lib/esm/resolvers/route-parameter-decorator.resolver.js.map +1 -1
  135. package/dist/lib/esm/router.js +25 -10
  136. package/dist/lib/esm/router.js.map +1 -1
  137. package/dist/types/decorators/body.decorator.d.ts +3 -0
  138. package/dist/types/decorators/controller.decorator.d.ts +4 -0
  139. package/dist/types/decorators/decorators.d.ts +1 -1
  140. package/dist/types/decorators/headers.decorator.d.ts +3 -0
  141. package/dist/types/decorators/identity.decorator.d.ts +3 -0
  142. package/dist/types/decorators/query-parameter.decorator.d.ts +4 -0
  143. package/dist/types/decorators/query-parameters.decorator.d.ts +3 -0
  144. package/dist/types/decorators/request.decorator.d.ts +3 -0
  145. package/dist/types/decorators/response-header.decorator.d.ts +7 -0
  146. package/dist/types/decorators/route-parameter.decorator.d.ts +4 -0
  147. package/dist/types/decorators/route.decorator.d.ts +6 -1
  148. package/dist/types/enrichers/router-response.enricher.d.ts +4 -0
  149. package/dist/types/errors/errors.d.ts +3 -1
  150. package/dist/types/errors/http.error.d.ts +1 -1
  151. package/dist/types/errors/method-router-adding.error.d.ts +10 -0
  152. package/dist/types/errors/path-router-adding.error.d.ts +4 -3
  153. package/dist/types/errors/path-router-instantiation.error.d.ts +4 -3
  154. package/dist/types/interfaces/controller-method-parameter-decorator-resolver.interface.d.ts +19 -2
  155. package/dist/types/interfaces/interfaces.d.ts +2 -2
  156. package/dist/types/interfaces/parameter-decorator.interface.d.ts +4 -0
  157. package/dist/types/interfaces/query-parameters-decorator.interface.d.ts +4 -0
  158. package/dist/types/interfaces/route-parameter-decorator.interface.d.ts +1 -1
  159. package/dist/types/interfaces/router.interface.d.ts +2 -2
  160. package/dist/types/models/models.d.ts +0 -1
  161. package/dist/types/models/request.d.ts +16 -4
  162. package/dist/types/models/response.d.ts +15 -0
  163. package/dist/types/models/route.d.ts +4 -0
  164. package/dist/types/nodes/method-router.node.d.ts +17 -4
  165. package/dist/types/nodes/path-router.node.d.ts +11 -7
  166. package/dist/types/nodes/router.node.d.ts +3 -3
  167. package/dist/types/resolvers/body-parameter-decorator.resolver.d.ts +22 -2
  168. package/dist/types/resolvers/controller-method-parameter-decorator.resolver.d.ts +14 -0
  169. package/dist/types/resolvers/headers-parameter-decorator.resolver.d.ts +22 -2
  170. package/dist/types/resolvers/identity-parameter-decorator.resolver.d.ts +22 -2
  171. package/dist/types/resolvers/query-parameter-decorator.resolver.d.ts +23 -2
  172. package/dist/types/resolvers/query-parameters-decorator.resolver.d.ts +22 -2
  173. package/dist/types/resolvers/request-parameter-decorator.resolver.d.ts +22 -2
  174. package/dist/types/resolvers/route-parameter-decorator.resolver.d.ts +22 -2
  175. package/dist/types/router.d.ts +13 -3
  176. package/package.json +5 -5
  177. package/dist/lib/cjs/enums/enums.js +0 -1
  178. package/dist/lib/cjs/enums/enums.js.map +0 -1
  179. package/dist/lib/cjs/models/error-response-body.js +0 -7
  180. package/dist/lib/cjs/models/error-response-body.js.map +0 -1
  181. package/dist/lib/esm/enums/enums.js +0 -1
  182. package/dist/lib/esm/enums/enums.js.map +0 -1
  183. package/dist/lib/esm/models/error-response-body.js +0 -3
  184. package/dist/lib/esm/models/error-response-body.js.map +0 -1
  185. package/dist/types/enums/enums.d.ts +0 -0
  186. 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;AAKrE,IAAa,iCAAiC,GAA9C,MAAa,iCAAiC;IAC1C,OAAO,CAAC,cAAmB,EACnB,OAAgB,EAChB,eAAwC,EACxC,QAA4B;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,QAAQ,CAAC,cAAmB;QACxB,OAAO,cAAc,IAAI,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,KAAK,SAAS,CAAC;IACxG,CAAC;CACJ,CAAA;AAXY,iCAAiC;IAH7C,qBAAY,CAAC,mDAAuB,CAAC;IACrC,YAAG,CAAC,iCAAwB,CAAC,gCAAgC,CAAC;IAC9D,qBAAU,EAAE;GACA,iCAAiC,CAW7C;AAXY,8EAAiC"}
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;AAKrE,IAAa,+BAA+B,GAA5C,MAAa,+BAA+B;IACxC,OAAO,CAAC,cAAmB,EACnB,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,QAAQ,CAAC,cAAmB;QACxB,OAAO,cAAc,IAAI,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,KAAK,gBAAgB,CAAC;IAC/G,CAAC;CACJ,CAAA;AAXY,+BAA+B;IAH3C,qBAAY,CAAC,mDAAuB,CAAC;IACrC,YAAG,CAAC,iCAAwB,CAAC,gCAAgC,CAAC;IAC9D,qBAAU,EAAE;GACA,+BAA+B,CAW3C;AAXY,0EAA+B"}
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"}
@@ -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
- constructor(loghandler, controllerMethodParameterDecoratorResolver, authorizerManager, authenticationManager, tracingManager) {
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 routerRequestExecutionSpan = this.tracingManager.startSpan(telemetry_1.SpanKeynameEnum.RouterRequestExecution, telemetry_1.SpanKeynameEnum.RequestExecution);
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 = this.tracingManager.startSpan(telemetry_1.SpanKeynameEnum.RouterFindMethodRouterNode, telemetry_1.SpanKeynameEnum.RouterRequestExecution);
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 = this.tracingManager.startSpan(telemetry_1.SpanKeynameEnum.RouterControllerResolver, telemetry_1.SpanKeynameEnum.RouterRequestExecution);
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 = this.tracingManager.startSpan(telemetry_1.SpanKeynameEnum.RouterRequestAuthentication, telemetry_1.SpanKeynameEnum.RouterRequestExecution);
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
- const requestEnrichersSpan = this.tracingManager.startSpan(telemetry_1.SpanKeynameEnum.RouterRequestEnrichers, telemetry_1.SpanKeynameEnum.RouterRequestExecution);
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 = this.tracingManager.startSpan(telemetry_1.SpanKeynameEnum.RouterResponseEnrichers, telemetry_1.SpanKeynameEnum.RouterRequestExecution);
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
- __param(4, tsyringe_1.inject("TracingManagerInterface")),
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;AAGtF,IAAa,MAAM,GAAnB,MAAa,MAAM;IAGf,YAAoE,UAA+B,EAC9D,0CAAsF,EAChD,iBAA6C,EACzC,qBAAqD,EAC5D,cAAuC;QAJ3C,eAAU,GAAV,UAAU,CAAqB;QAC9D,+CAA0C,GAA1C,0CAA0C,CAA4C;QAChD,sBAAiB,GAAjB,iBAAiB,CAA4B;QACzC,0BAAqB,GAArB,qBAAqB,C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,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 (target, propertyKey, parameterIndex) => {
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":["../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AAe,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 (constructor) => {
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,CAAC,WAAqB,EAAE,EAAE;QAC7B,IAAG,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,KAAK,EAAE;YAC/D,WAAW,CAAC,SAAS,C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D,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,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,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 (target, propertyKey, parameterIndex) => {
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":"AAGA,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE;IACxB,OAAO,CACH,MAAc,EACd,WAA4B,EAC5B,cAAsB,EACxB,EAAE;QACA,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,K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S,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 (target, propertyKey, parameterIndex) => {
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,CACH,MAAc,EACd,WAA4B,EAC5B,cAAsB,EACxB,EAAE;QACA,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,CA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,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 (target, propertyKey, parameterIndex) => {
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,CACH,MAAc,EACd,WAA4B,EAC5B,cAAsB,EACxB,EAAE;QACA,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,MAAM,eAAe,GAAqC;YACtD,IAAI,EAAE,gBAAgB;YACtB,kBAAkB,EAAE,IAAI;SAC3B,CAAC;QAEF,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
+ {"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 (target, propertyKey, parameterIndex) => {
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,CACH,MAAc,EACd,WAA4B,EAC5B,cAAsB,EACxB,EAAE;QACA,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,MAAM,eAAe,GAAsC;YACvD,IAAI,EAAE,iBAAiB;SAC1B,CAAC;QAEF,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
+ {"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,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,MAAM,eAAe,GAAsC;YACvD,IAAI,EAAE,iBAAiB;SAC1B,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 request decorator 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 (target, propertyKey, parameterIndex) => {
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,CACH,MAAc,EACd,WAA4B,EAC5B,cAAsB,EACxB,EAAE;QACA,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,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;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,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 (target, propertyKey, descriptor) => {
3
- // If there's a descriptor, then it's not a controller guard, but a method guard
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,CAAE,MAAW,EACX,WAAoB,EACpB,UAA+B,EAAE,EAAE;QAExC,gFAAgF;QAChF,IAAG,UAAU,IAAI,WAAW,EAAE;YAC1B,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,W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AAG,EAAE,CAAA;aACtD;YAED,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC,cAAc,CAAC,kBAAkB,CAAC,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
+ {"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,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B,IAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,KAAK,EAAE;gBAC1D,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,CAAA;aACxC;YAED,IAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,YAAY,CAAC,KAAK,KAAK,EAAE;gBACxE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC,GAAG,EAAE,CAAA;aACtD;YAED,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC,cAAc,CAAC,kBAAkB,CAAC,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 (target, propertyKey, parameterIndex) => {
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
  };