hono 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/dist/context.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /// <reference types="@cloudflare/workers-types" />
2
- import type { Environment, NotFoundHandler, ContextVariableMap, Bindings } from './hono';
2
+ import type { Environment, NotFoundHandler, ContextVariableMap } from './hono';
3
3
  import type { CookieOptions } from './utils/cookie';
4
4
  import type { StatusCode } from './utils/http-status';
5
5
  declare type Headers = Record<string, string>;
6
6
  export declare type Data = string | ArrayBuffer | ReadableStream;
7
7
  export interface Context<RequestParamKeyType extends string = string, E extends Partial<Environment> = Environment> {
8
8
  req: Request<RequestParamKeyType>;
9
- env: E['Bindings'] | Bindings;
9
+ env: E['Bindings'];
10
10
  event: FetchEvent;
11
11
  executionCtx: ExecutionContext;
12
12
  finalized: boolean;
@@ -36,7 +36,7 @@ export interface Context<RequestParamKeyType extends string = string, E extends
36
36
  }
37
37
  export declare class HonoContext<RequestParamKeyType extends string = string, E extends Partial<Environment> = Environment> implements Context<RequestParamKeyType, E> {
38
38
  req: Request<RequestParamKeyType>;
39
- env: Environment['Bindings'];
39
+ env: E['Bindings'];
40
40
  finalized: boolean;
41
41
  _status: StatusCode;
42
42
  private _executionCtx;
package/dist/hono.d.ts CHANGED
@@ -16,10 +16,10 @@ export declare type Next = () => Promise<void>;
16
16
  declare type ParamKeyName<NameWithPattern> = NameWithPattern extends `${infer Name}{${infer _Pattern}` ? Name : NameWithPattern;
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
- interface HandlerInterface<T extends string, E extends Partial<Environment> = Environment, U = Hono<E, T>> {
20
- <Path extends string>(path: Path, ...handlers: Handler<ParamKeys<Path> extends never ? string : ParamKeys<Path>, E>[]): U;
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
21
  (path: string, ...handlers: Handler<string, E>[]): U;
22
- <Path extends string>(...handlers: Handler<ParamKeys<Path> extends never ? string : ParamKeys<Path>, E>[]): U;
22
+ <Path extends string, Env extends Partial<Environment> = E>(...handlers: Handler<ParamKeys<Path> extends never ? string : ParamKeys<Path>, Env>[]): U;
23
23
  (...handlers: Handler<string, E>[]): U;
24
24
  }
25
25
  interface Route<E extends Partial<Environment> = Environment> {
@@ -50,8 +50,8 @@ export declare class Hono<E extends {
50
50
  private notFoundHandler;
51
51
  private errorHandler;
52
52
  route(path: string, app?: Hono<any>): Hono<E, P>;
53
- use(path: string, ...middleware: Handler<string, E>[]): Hono<E, P>;
54
- use(...middleware: Handler<string, E>[]): Hono<E, P>;
53
+ use<Path extends string = string, Env extends Partial<Environment> = E>(...middleware: Handler<Path, Env>[]): Hono<Env, Path>;
54
+ use<Path extends string = string, Env extends Partial<Environment> = E>(arg1: string, ...middleware: Handler<Path, Env>[]): Hono<Env, Path>;
55
55
  onError(handler: ErrorHandler): Hono<E, P>;
56
56
  notFound(handler: NotFoundHandler): Hono<E, P>;
57
57
  private addRoute;
@@ -1,3 +1,3 @@
1
1
  import type { ServeStaticOptions } from './serve-static';
2
- declare const module: (options?: ServeStaticOptions) => import("../../hono").Handler<string, import("../../hono").Environment>;
2
+ declare const module: (options?: ServeStaticOptions) => (c: import("../../context").Context<string, import("../../hono").Environment>, next: import("../../hono").Next) => Promise<Response | undefined>;
3
3
  export { module as serveStatic };
@@ -1,9 +1,10 @@
1
1
  /// <reference types="@cloudflare/workers-types" />
2
- import type { Handler } from '../../hono';
2
+ import type { Context } from '../../context';
3
+ import type { Next } from '../../hono';
3
4
  export declare type ServeStaticOptions = {
4
5
  root?: string;
5
6
  path?: string;
6
7
  manifest?: object | string;
7
8
  namespace?: KVNamespace;
8
9
  };
9
- export declare const serveStatic: (options?: ServeStaticOptions) => Handler;
10
+ export declare const serveStatic: (options?: ServeStaticOptions) => (c: Context, next: Next) => Promise<Response | undefined>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Ultrafast web framework for Cloudflare Workers.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",