hono 3.10.1 → 3.10.2

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.
@@ -44,7 +44,7 @@ const compose = (middleware, onError, onNotFound) => {
44
44
  }
45
45
  if (!handler) {
46
46
  if (context instanceof import_context.Context && context.finalized === false && onNotFound) {
47
- res = onNotFound(context);
47
+ res = await onNotFound(context);
48
48
  }
49
49
  } else {
50
50
  try {
@@ -54,7 +54,7 @@ const compose = (middleware, onError, onNotFound) => {
54
54
  } catch (err) {
55
55
  if (err instanceof Error && context instanceof import_context.Context && onError) {
56
56
  context.error = err;
57
- res = onError(err, context);
57
+ res = await onError(err, context);
58
58
  isError = true;
59
59
  } else {
60
60
  throw err;
@@ -212,7 +212,7 @@ class Hono extends defineDynamicClass() {
212
212
  }
213
213
  const path = this.getPath(request, { env });
214
214
  const [handlers, paramStash] = this.matchRoute(method, path);
215
- const c = new import_context.Context(new import_request.HonoRequest(request, path, paramStash || []), {
215
+ const c = new import_context.Context(new import_request.HonoRequest(request, path, paramStash), {
216
216
  env,
217
217
  executionCtx,
218
218
  notFoundHandler: this.notFoundHandler
@@ -25,7 +25,7 @@ var import_body = require("./utils/body");
25
25
  var import_cookie = require("./utils/cookie");
26
26
  var import_url = require("./utils/url");
27
27
  class HonoRequest {
28
- constructor(request, path = "/", paramStash = []) {
28
+ constructor(request, path = "/", paramStash = void 0) {
29
29
  this._p = {};
30
30
  this.bodyCache = {};
31
31
  this.cachedBody = (key) => {
@@ -49,24 +49,21 @@ class HonoRequest {
49
49
  this._p = params;
50
50
  }
51
51
  param(key) {
52
- if (this._s) {
53
- if (key) {
54
- const param = this._s[this._p[key]] ?? this._p[key];
55
- return param ? /\%/.test(param) ? (0, import_url.decodeURIComponent_)(param) : param : void 0;
56
- } else {
57
- const decoded = {};
58
- const keys = Object.keys(this._p);
59
- for (let i = 0, len = keys.length; i < len; i++) {
60
- const key2 = keys[i];
61
- const value = this._s[this._p[key2]] ?? this._p[key2];
62
- if (value && typeof value === "string") {
63
- decoded[key2] = /\%/.test(value) ? (0, import_url.decodeURIComponent_)(value) : value;
64
- }
52
+ if (key) {
53
+ const param = this._s ? this._s[this._p[key]] : this._p[key];
54
+ return param ? /\%/.test(param) ? (0, import_url.decodeURIComponent_)(param) : param : void 0;
55
+ } else {
56
+ const decoded = {};
57
+ const keys = Object.keys(this._p);
58
+ for (let i = 0, len = keys.length; i < len; i++) {
59
+ const key2 = keys[i];
60
+ const value = this._s ? this._s[this._p[key2]] : this._p[key2];
61
+ if (value && typeof value === "string") {
62
+ decoded[key2] = /\%/.test(value) ? (0, import_url.decodeURIComponent_)(value) : value;
65
63
  }
66
- return decoded;
67
64
  }
65
+ return decoded;
68
66
  }
69
- return null;
70
67
  }
71
68
  query(key) {
72
69
  return (0, import_url.getQueryParam)(this.url, key);
package/dist/compose.js CHANGED
@@ -22,7 +22,7 @@ var compose = (middleware, onError, onNotFound) => {
22
22
  }
23
23
  if (!handler) {
24
24
  if (context instanceof Context && context.finalized === false && onNotFound) {
25
- res = onNotFound(context);
25
+ res = await onNotFound(context);
26
26
  }
27
27
  } else {
28
28
  try {
@@ -32,7 +32,7 @@ var compose = (middleware, onError, onNotFound) => {
32
32
  } catch (err) {
33
33
  if (err instanceof Error && context instanceof Context && onError) {
34
34
  context.error = err;
35
- res = onError(err, context);
35
+ res = await onError(err, context);
36
36
  isError = true;
37
37
  } else {
38
38
  throw err;
package/dist/hono-base.js CHANGED
@@ -190,7 +190,7 @@ var Hono = class extends defineDynamicClass() {
190
190
  }
191
191
  const path = this.getPath(request, { env });
192
192
  const [handlers, paramStash] = this.matchRoute(method, path);
193
- const c = new Context(new HonoRequest(request, path, paramStash || []), {
193
+ const c = new Context(new HonoRequest(request, path, paramStash), {
194
194
  env,
195
195
  executionCtx,
196
196
  notFoundHandler: this.notFoundHandler
package/dist/request.js CHANGED
@@ -3,7 +3,7 @@ import { parseBody } from "./utils/body.js";
3
3
  import { parse } from "./utils/cookie.js";
4
4
  import { getQueryParam, getQueryParams, decodeURIComponent_ } from "./utils/url.js";
5
5
  var HonoRequest = class {
6
- constructor(request, path = "/", paramStash = []) {
6
+ constructor(request, path = "/", paramStash = void 0) {
7
7
  this._p = {};
8
8
  this.bodyCache = {};
9
9
  this.cachedBody = (key) => {
@@ -27,24 +27,21 @@ var HonoRequest = class {
27
27
  this._p = params;
28
28
  }
29
29
  param(key) {
30
- if (this._s) {
31
- if (key) {
32
- const param = this._s[this._p[key]] ?? this._p[key];
33
- return param ? /\%/.test(param) ? decodeURIComponent_(param) : param : void 0;
34
- } else {
35
- const decoded = {};
36
- const keys = Object.keys(this._p);
37
- for (let i = 0, len = keys.length; i < len; i++) {
38
- const key2 = keys[i];
39
- const value = this._s[this._p[key2]] ?? this._p[key2];
40
- if (value && typeof value === "string") {
41
- decoded[key2] = /\%/.test(value) ? decodeURIComponent_(value) : value;
42
- }
30
+ if (key) {
31
+ const param = this._s ? this._s[this._p[key]] : this._p[key];
32
+ return param ? /\%/.test(param) ? decodeURIComponent_(param) : param : void 0;
33
+ } else {
34
+ const decoded = {};
35
+ const keys = Object.keys(this._p);
36
+ for (let i = 0, len = keys.length; i < len; i++) {
37
+ const key2 = keys[i];
38
+ const value = this._s ? this._s[this._p[key2]] : this._p[key2];
39
+ if (value && typeof value === "string") {
40
+ decoded[key2] = /\%/.test(value) ? decodeURIComponent_(value) : value;
43
41
  }
44
- return decoded;
45
42
  }
43
+ return decoded;
46
44
  }
47
- return null;
48
45
  }
49
46
  query(key) {
50
47
  return getQueryParam(this.url, key);
@@ -32,7 +32,7 @@ export interface LambdaFunctionUrlEvent {
32
32
  isBase64Encoded: boolean;
33
33
  requestContext: LambdaFunctionUrlRequestContext;
34
34
  }
35
- interface APIGatewayProxyResult {
35
+ export interface APIGatewayProxyResult {
36
36
  statusCode: number;
37
37
  body: string;
38
38
  headers: Record<string, string>;
@@ -49,4 +49,3 @@ export declare const streamHandle: <E extends Env = Env, S extends Schema = {},
49
49
  export declare const handle: <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => (event: APIGatewayProxyEvent | APIGatewayProxyEventV2 | LambdaFunctionUrlEvent, lambdaContext?: LambdaContext) => Promise<APIGatewayProxyResult>;
50
50
  export declare const isContentTypeBinary: (contentType: string) => boolean;
51
51
  export declare const isContentEncodingBinary: (contentEncoding: string | null) => boolean;
52
- export {};
@@ -1,3 +1,4 @@
1
1
  export { handle, streamHandle } from './handler';
2
+ export type { APIGatewayProxyResult } from './handler';
2
3
  export type { ApiGatewayRequestContext, LambdaFunctionUrlRequestContext } from './custom-context';
3
4
  export type { LambdaContext } from './types';
@@ -20,7 +20,7 @@ export declare class HonoRequest<P extends string = '/', I extends Input['out']
20
20
  private _p;
21
21
  path: string;
22
22
  bodyCache: BodyCache;
23
- constructor(request: Request, path?: string, paramStash?: ParamStash);
23
+ constructor(request: Request, path?: string, paramStash?: ParamStash | undefined);
24
24
  setParams(params: ParamIndexMap | Params): void;
25
25
  param<P2 extends string = P>(key: RemoveQuestion<ParamKeys<P2>>): UndefinedIfHavingQuestion<ParamKeys<P2>>;
26
26
  param<P2 extends string = P>(): UnionToIntersection<ParamKeyToRecord<ParamKeys<P2>>>;
@@ -25,7 +25,7 @@ export interface HandlerInterface<E extends Env = Env, M extends string = string
25
25
  <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, I extends Input = {}, R extends HandlerResponse<any> = any, E2 extends Env = E>(handler: H<E2, P, I, R>): Hono<E & E2, S & ToSchema<M, P, I['in'], MergeTypedResponseData<R>>, BasePath>;
26
26
  <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, I extends Input = {}, R extends HandlerResponse<any> = any, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>>(...handlers: [H<E2, P, I, R>, H<E3, P, I, R>]): Hono<E & E2 & E3, S & ToSchema<M, P, I['in'], MergeTypedResponseData<R>>, BasePath>;
27
27
  <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, R extends HandlerResponse<any> = any, I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>>(...handlers: [H<E2, P, I, R>, H<E3, P, I2, R>, H<E4, P, I3, R>]): Hono<E & E2 & E3 & E4, S & ToSchema<M, P, I3['in'], MergeTypedResponseData<R>>, BasePath>;
28
- <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, R extends HandlerResponse<any> = any, I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4]>>(...handlers: [H<E2, P, I, R>, H<E3, P, I2, R>, H<E4, P, I3, R>, H<E5, P, I3, R>]): Hono<E & E2 & E3 & E4 & E5, S & ToSchema<M, P, I4['in'], MergeTypedResponseData<R>>, BasePath>;
28
+ <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, R extends HandlerResponse<any> = any, I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4]>>(...handlers: [H<E2, P, I, R>, H<E3, P, I2, R>, H<E4, P, I3, R>, H<E5, P, I4, R>]): Hono<E & E2 & E3 & E4 & E5, S & ToSchema<M, P, I4['in'], MergeTypedResponseData<R>>, BasePath>;
29
29
  <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, R extends HandlerResponse<any> = any, I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I2 & I3, I5 extends Input = I & I2 & I3 & I4, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5]>>(...handlers: [
30
30
  H<E2, P, I, R>,
31
31
  H<E3, P, I2, R>,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "3.10.1",
3
+ "version": "3.10.2",
4
4
  "description": "Ultrafast web framework for the Edges",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",