@aklinker1/zeta 2.1.0 → 2.1.1
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/package.json
CHANGED
package/src/internal/context.ts
CHANGED
|
@@ -11,6 +11,10 @@ export class Context {
|
|
|
11
11
|
|
|
12
12
|
matchedRoute: MatchedRoute<RouterData> | undefined;
|
|
13
13
|
|
|
14
|
+
// Private storage for overwritten values
|
|
15
|
+
#params: Record<string, any> | undefined;
|
|
16
|
+
#query: Record<string, any> | undefined;
|
|
17
|
+
|
|
14
18
|
constructor(
|
|
15
19
|
public request: Request,
|
|
16
20
|
public path: string,
|
|
@@ -21,14 +25,28 @@ export class Context {
|
|
|
21
25
|
return new URL(this.request.url, this.origin);
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
get params(): Record<string,
|
|
28
|
+
get params(): Record<string, any> {
|
|
29
|
+
if (this.#params !== undefined) {
|
|
30
|
+
return this.#params;
|
|
31
|
+
}
|
|
25
32
|
return this.matchedRoute?.params ? getRawParams(this.matchedRoute) : {};
|
|
26
33
|
}
|
|
27
34
|
|
|
28
|
-
|
|
35
|
+
set params(value: Record<string, any>) {
|
|
36
|
+
this.#params = value;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get query(): Record<string, any> {
|
|
40
|
+
if (this.#query !== undefined) {
|
|
41
|
+
return this.#query;
|
|
42
|
+
}
|
|
29
43
|
return this.request.url.includes("?") ? getRawQuery(this.request) : {};
|
|
30
44
|
}
|
|
31
45
|
|
|
46
|
+
set query(value: Record<string, any>) {
|
|
47
|
+
this.#query = value;
|
|
48
|
+
}
|
|
49
|
+
|
|
32
50
|
get route(): string | undefined {
|
|
33
51
|
return this.matchedRoute?.data.route;
|
|
34
52
|
}
|