@fluojs/http 1.0.0-beta.8 → 1.0.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch-routing-policy.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatch-routing-policy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElG;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,GAAG,YAAY,CAQ3G;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAOlH"}
1
+ {"version":3,"file":"dispatch-routing-policy.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatch-routing-policy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElG;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,GAAG,YAAY,CAQ3G;AA2BD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAsBlH"}
@@ -13,6 +13,25 @@ export function matchHandlerOrThrow(handlerMapping, request) {
13
13
  }
14
14
  return match;
15
15
  }
16
+ function defineRequestParams(request, params) {
17
+ Object.defineProperty(request, 'params', {
18
+ configurable: true,
19
+ enumerable: true,
20
+ value: params,
21
+ writable: true
22
+ });
23
+ }
24
+ function findInheritedParamsDescriptor(request) {
25
+ let prototype = Object.getPrototypeOf(request);
26
+ while (prototype) {
27
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, 'params');
28
+ if (descriptor) {
29
+ return descriptor;
30
+ }
31
+ prototype = Object.getPrototypeOf(prototype);
32
+ }
33
+ return undefined;
34
+ }
16
35
 
17
36
  /**
18
37
  * Update request params.
@@ -21,10 +40,20 @@ export function matchHandlerOrThrow(handlerMapping, request) {
21
40
  * @param params The params.
22
41
  */
23
42
  export function updateRequestParams(requestContext, params) {
24
- Object.defineProperty(requestContext.request, 'params', {
25
- configurable: true,
26
- enumerable: true,
27
- value: params,
28
- writable: true
29
- });
43
+ const request = requestContext.request;
44
+ const ownDescriptor = Object.getOwnPropertyDescriptor(request, 'params');
45
+ if (ownDescriptor) {
46
+ if ('value' in ownDescriptor && ownDescriptor.writable) {
47
+ request.params = params;
48
+ return;
49
+ }
50
+ defineRequestParams(request, params);
51
+ return;
52
+ }
53
+ const inheritedDescriptor = findInheritedParamsDescriptor(request);
54
+ if (!inheritedDescriptor || 'value' in inheritedDescriptor && inheritedDescriptor.writable) {
55
+ request.params = params;
56
+ return;
57
+ }
58
+ defineRequestParams(request, params);
30
59
  }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "controller",
11
11
  "rest"
12
12
  ],
13
- "version": "1.0.0-beta.8",
13
+ "version": "1.0.0-beta.9",
14
14
  "private": false,
15
15
  "license": "MIT",
16
16
  "repository": {
@@ -42,8 +42,8 @@
42
42
  ],
43
43
  "dependencies": {
44
44
  "@fluojs/core": "^1.0.0-beta.2",
45
- "@fluojs/di": "^1.0.0-beta.5",
46
- "@fluojs/validation": "^1.0.0-beta.1"
45
+ "@fluojs/validation": "^1.0.0-beta.1",
46
+ "@fluojs/di": "^1.0.0-beta.5"
47
47
  },
48
48
  "devDependencies": {
49
49
  "vitest": "^3.2.4"