hono 2.1.2 → 2.1.3

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/compose.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import type { ErrorHandler, NotFoundHandler } from './hono';
2
- export declare const compose: <C>(middleware: Function[], onError?: ErrorHandler<import("./hono").Environment> | undefined, onNotFound?: NotFoundHandler<import("./hono").Environment> | undefined) => (context: C, next?: Function | undefined) => Promise<C>;
1
+ import type { NotFoundHandler } from './hono';
2
+ export declare const compose: <C>(middleware: Function[], onNotFound?: NotFoundHandler<import("./hono").Environment> | undefined) => (context: C, next?: Function | undefined) => Promise<C>;
package/dist/compose.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.compose = void 0;
4
4
  const context_1 = require("./context");
5
5
  // Based on the code in the MIT licensed `koa-compose` package.
6
- const compose = (middleware, onError, onNotFound) => {
6
+ const compose = (middleware, onNotFound) => {
7
7
  const middlewareLength = middleware.length;
8
8
  return (context, next) => {
9
9
  let index = -1;
@@ -22,24 +22,9 @@ const compose = (middleware, onError, onNotFound) => {
22
22
  }
23
23
  return context;
24
24
  }
25
- let res;
26
- let isError = false;
27
- try {
28
- const tmp = handler(context, () => dispatch(i + 1));
29
- res = tmp instanceof Promise ? await tmp : tmp;
30
- }
31
- catch (err) {
32
- if (context instanceof context_1.HonoContext && onError) {
33
- if (err instanceof Error) {
34
- isError = true;
35
- res = onError(err, context);
36
- }
37
- }
38
- if (!res) {
39
- throw err;
40
- }
41
- }
42
- if (res && context instanceof context_1.HonoContext && (!context.finalized || isError)) {
25
+ const tmp = handler(context, () => dispatch(i + 1));
26
+ const res = tmp instanceof Promise ? await tmp : tmp;
27
+ if (res && context instanceof context_1.HonoContext && context.finalized === false) {
43
28
  context.res = res;
44
29
  }
45
30
  return context;
package/dist/hono.d.ts CHANGED
@@ -17,10 +17,10 @@ declare type ParamKeyName<NameWithPattern> = NameWithPattern extends `${infer Na
17
17
  declare type ParamKey<Component> = Component extends `:${infer NameWithPattern}` ? ParamKeyName<NameWithPattern> : never;
18
18
  declare type ParamKeys<Path> = Path extends `${infer Component}/${infer Rest}` ? ParamKey<Component> | ParamKeys<Rest> : ParamKey<Path>;
19
19
  interface HandlerInterface<T extends string = string, E extends Partial<Environment> = Environment, U = Hono<E, T>> {
20
- <Path extends string, Env extends Partial<Environment> = E>(path: Path, ...handlers: Handler<ParamKeys<Path> extends never ? string : ParamKeys<Path>, Env>[]): U;
21
- (path: string, ...handlers: Handler<string, E>[]): U;
22
20
  <Path extends string, Env extends Partial<Environment> = E>(...handlers: Handler<ParamKeys<Path> extends never ? string : ParamKeys<Path>, Env>[]): U;
23
21
  (...handlers: Handler<string, E>[]): U;
22
+ <Path extends string, Env extends Partial<Environment> = E>(path: Path, ...handlers: Handler<ParamKeys<Path> extends never ? string : ParamKeys<Path>, Env>[]): U;
23
+ (path: string, ...handlers: Handler<string, E>[]): U;
24
24
  }
25
25
  interface Route<E extends Partial<Environment> = Environment> {
26
26
  path: string;
package/dist/hono.js CHANGED
@@ -101,7 +101,7 @@ class Hono extends defineDynamicClass() {
101
101
  request.paramData = result?.params;
102
102
  const handlers = result ? result.handlers : [this.notFoundHandler];
103
103
  const c = new context_1.HonoContext(request, env, eventOrExecutionCtx, this.notFoundHandler);
104
- const composed = (0, compose_1.compose)(handlers, this.errorHandler, this.notFoundHandler);
104
+ const composed = (0, compose_1.compose)(handlers, this.notFoundHandler);
105
105
  let context;
106
106
  try {
107
107
  context = await composed(c);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "Ultrafast web framework for Cloudflare Workers.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",