hono 3.12.7 → 3.12.8
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/cjs/hono-base.js +2 -4
- package/dist/cjs/request.js +18 -13
- package/dist/hono-base.js +2 -4
- package/dist/request.js +18 -13
- package/dist/types/helper/factory/index.d.ts +1 -1
- package/dist/types/request.d.ts +3 -0
- package/package.json +1 -1
package/dist/cjs/hono-base.js
CHANGED
|
@@ -253,11 +253,9 @@ const _Hono = class extends defineDynamicClass() {
|
|
|
253
253
|
} catch (err) {
|
|
254
254
|
return this.handleError(err, c);
|
|
255
255
|
}
|
|
256
|
-
|
|
257
|
-
return res;
|
|
258
|
-
return res.then(
|
|
256
|
+
return res instanceof Promise ? res.then(
|
|
259
257
|
(resolved) => resolved || (c.finalized ? c.res : this.notFoundHandler(c))
|
|
260
|
-
).catch((err) => this.handleError(err, c));
|
|
258
|
+
).catch((err) => this.handleError(err, c)) : res;
|
|
261
259
|
}
|
|
262
260
|
const composed = (0, import_compose.compose)(matchResult[0], this.errorHandler, this.notFoundHandler);
|
|
263
261
|
return (async () => {
|
package/dist/cjs/request.js
CHANGED
|
@@ -67,21 +67,26 @@ class HonoRequest {
|
|
|
67
67
|
__privateSet(this, _validatedData, {});
|
|
68
68
|
}
|
|
69
69
|
param(key) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
return key ? this.getDecodedParam(key) : this.getAllDecodedParams();
|
|
71
|
+
}
|
|
72
|
+
getDecodedParam(key) {
|
|
73
|
+
const paramKey = __privateGet(this, _matchResult)[0][this.routeIndex][1][key];
|
|
74
|
+
const param = this.getParamValue(paramKey);
|
|
75
|
+
return param ? /\%/.test(param) ? (0, import_url.decodeURIComponent_)(param) : param : void 0;
|
|
76
|
+
}
|
|
77
|
+
getAllDecodedParams() {
|
|
78
|
+
const decoded = {};
|
|
79
|
+
const keys = Object.keys(__privateGet(this, _matchResult)[0][this.routeIndex][1]);
|
|
80
|
+
for (const key of keys) {
|
|
81
|
+
const value = this.getParamValue(__privateGet(this, _matchResult)[0][this.routeIndex][1][key]);
|
|
82
|
+
if (value && typeof value === "string") {
|
|
83
|
+
decoded[key] = /\%/.test(value) ? (0, import_url.decodeURIComponent_)(value) : value;
|
|
82
84
|
}
|
|
83
|
-
return decoded;
|
|
84
85
|
}
|
|
86
|
+
return decoded;
|
|
87
|
+
}
|
|
88
|
+
getParamValue(paramKey) {
|
|
89
|
+
return __privateGet(this, _matchResult)[1] ? __privateGet(this, _matchResult)[1][paramKey] : paramKey;
|
|
85
90
|
}
|
|
86
91
|
query(key) {
|
|
87
92
|
return (0, import_url.getQueryParam)(this.url, key);
|
package/dist/hono-base.js
CHANGED
|
@@ -231,11 +231,9 @@ var _Hono = class extends defineDynamicClass() {
|
|
|
231
231
|
} catch (err) {
|
|
232
232
|
return this.handleError(err, c);
|
|
233
233
|
}
|
|
234
|
-
|
|
235
|
-
return res;
|
|
236
|
-
return res.then(
|
|
234
|
+
return res instanceof Promise ? res.then(
|
|
237
235
|
(resolved) => resolved || (c.finalized ? c.res : this.notFoundHandler(c))
|
|
238
|
-
).catch((err) => this.handleError(err, c));
|
|
236
|
+
).catch((err) => this.handleError(err, c)) : res;
|
|
239
237
|
}
|
|
240
238
|
const composed = compose(matchResult[0], this.errorHandler, this.notFoundHandler);
|
|
241
239
|
return (async () => {
|
package/dist/request.js
CHANGED
|
@@ -46,21 +46,26 @@ var HonoRequest = class {
|
|
|
46
46
|
__privateSet(this, _validatedData, {});
|
|
47
47
|
}
|
|
48
48
|
param(key) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
return key ? this.getDecodedParam(key) : this.getAllDecodedParams();
|
|
50
|
+
}
|
|
51
|
+
getDecodedParam(key) {
|
|
52
|
+
const paramKey = __privateGet(this, _matchResult)[0][this.routeIndex][1][key];
|
|
53
|
+
const param = this.getParamValue(paramKey);
|
|
54
|
+
return param ? /\%/.test(param) ? decodeURIComponent_(param) : param : void 0;
|
|
55
|
+
}
|
|
56
|
+
getAllDecodedParams() {
|
|
57
|
+
const decoded = {};
|
|
58
|
+
const keys = Object.keys(__privateGet(this, _matchResult)[0][this.routeIndex][1]);
|
|
59
|
+
for (const key of keys) {
|
|
60
|
+
const value = this.getParamValue(__privateGet(this, _matchResult)[0][this.routeIndex][1][key]);
|
|
61
|
+
if (value && typeof value === "string") {
|
|
62
|
+
decoded[key] = /\%/.test(value) ? decodeURIComponent_(value) : value;
|
|
61
63
|
}
|
|
62
|
-
return decoded;
|
|
63
64
|
}
|
|
65
|
+
return decoded;
|
|
66
|
+
}
|
|
67
|
+
getParamValue(paramKey) {
|
|
68
|
+
return __privateGet(this, _matchResult)[1] ? __privateGet(this, _matchResult)[1][paramKey] : paramKey;
|
|
64
69
|
}
|
|
65
70
|
query(key) {
|
|
66
71
|
return getQueryParam(this.url, key);
|
|
@@ -111,4 +111,4 @@ export declare class Factory<E extends Env = any, P extends string = any> {
|
|
|
111
111
|
* The API might be changed.
|
|
112
112
|
*/
|
|
113
113
|
export declare const createFactory: <E extends Env = any, P extends string = any>() => Factory<E, P>;
|
|
114
|
-
export declare const createMiddleware: <E extends Env = any, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler) => MiddlewareHandler<E, P, I>;
|
|
114
|
+
export declare const createMiddleware: <E extends Env = any, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>) => MiddlewareHandler<E, P, I>;
|
package/dist/types/request.d.ts
CHANGED
|
@@ -22,6 +22,9 @@ export declare class HonoRequest<P extends string = '/', I extends Input['out']
|
|
|
22
22
|
constructor(request: Request, path?: string, matchResult?: Result<[unknown, RouterRoute]>);
|
|
23
23
|
param<P2 extends string = P>(key: RemoveQuestion<ParamKeys<P2>>): UndefinedIfHavingQuestion<ParamKeys<P2>>;
|
|
24
24
|
param<P2 extends string = P>(): UnionToIntersection<ParamKeyToRecord<ParamKeys<P2>>>;
|
|
25
|
+
private getDecodedParam;
|
|
26
|
+
private getAllDecodedParams;
|
|
27
|
+
private getParamValue;
|
|
25
28
|
query(key: string): string | undefined;
|
|
26
29
|
query(): Record<string, string>;
|
|
27
30
|
queries(key: string): string[] | undefined;
|