hono 1.6.2 → 1.6.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/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
  [![GitHub last commit](https://img.shields.io/github/last-commit/honojs/hono)](https://github.com/honojs/hono/commits/master)
16
16
  [![Deno badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Flatest-version%2Fx%2Fhono%2Fmod.ts)](https://doc.deno.land/https/deno.land/x/hono/mod.ts)
17
17
 
18
- Hono - _**[炎] means flame🔥 in Japanese**_ - is a small, simple, and ultrafast web framework for Cloudflare Workers, Deno, and others.
18
+ Hono - _**[炎] means flame🔥 in Japanese**_ - is a small, simple, and ultrafast web framework for Cloudflare Workers, Deno, Bun, and others.
19
19
 
20
20
  ```ts
21
21
  import { Hono } from 'hono'
@@ -32,7 +32,7 @@ app.fire()
32
32
  - **Zero-dependencies** - using only Service Worker and Web Standard API.
33
33
  - **Middleware** - built-in middleware and ability to extend with your own middleware.
34
34
  - **TypeScript** - first-class TypeScript support.
35
- - **Multi-platform** - works on Cloudflare Workers, Fastly Compute@Edge, or Deno.
35
+ - **Multi-platform** - works on Cloudflare Workers, Fastly Compute@Edge, Deno, or Bun.
36
36
 
37
37
  ## Benchmarks
38
38
 
@@ -69,6 +69,8 @@ Fastest is hono - regexp-router
69
69
  | oak | 10.5.1 | 2385k requests in 40.02s, 403 MB read |
70
70
  | opine | 2.2.0 | 1491k requests in 40.02s, 346 MB read |
71
71
 
72
+ Another benchmark result: [denosaurs/bench](https://github.com/denosaurs/bench)
73
+
72
74
  ## Why so fast?
73
75
 
74
76
  Routers used in Hono are really smart.
@@ -101,7 +103,7 @@ Built-in middleware make _"**Write Less, do more**"_ in reality. You can use a l
101
103
  - [Logger](https://github.com/honojs/hono/tree/master/src/middleware/logger/)
102
104
  - [Mustache template engine](https://github.com/honojs/hono/tree/master/src/middleware/mustache/) (Only for Cloudflare Workers)
103
105
  - [JSON pretty printing](https://github.com/honojs/hono/tree/master/src/middleware/pretty-json/)
104
- - [Serving static files](https://github.com/honojs/hono/tree/master/src/middleware/serve-static/) (Only for Cloudflare Workers)
106
+ - [Serving static files](https://github.com/honojs/hono/tree/master/src/middleware/serve-static/) (Only for Cloudflare Workers and Deno)
105
107
 
106
108
  To enable logger and Etag middleware with just this code.
107
109
 
@@ -758,11 +760,11 @@ export default app
758
760
 
759
761
  ## Deno
760
762
 
761
- Hono also works with Deno. This feature is still experimental.
763
+ Hono also works on Deno. This feature is still experimental.
762
764
 
763
765
  ```tsx
764
766
  /** @jsx jsx */
765
- import { serve } from 'https://deno.land/std@0.146.0/http/server.ts'
767
+ import { serve } from 'https://deno.land/std/http/server.ts'
766
768
  import { Hono, logger, poweredBy, serveStatic, jsx } from 'https://deno.land/x/hono/mod.ts'
767
769
 
768
770
  const app = new Hono()
@@ -774,7 +776,26 @@ app.get('/', (c) => {
774
776
  return c.html(<h1>Hello Deno!</h1>)
775
777
  })
776
778
 
777
- serve((req) => app.fetch(req))
779
+ serve(app.fetch)
780
+ ```
781
+
782
+ ## Bun
783
+
784
+ Hono also works on Bun. This feature is still experimental.
785
+
786
+ ```ts
787
+ import { Hono } from 'hono'
788
+
789
+ const app = new Hono()
790
+
791
+ app.get('/', (c) => {
792
+ return c.json({ message: 'Hello Bun!' })
793
+ })
794
+
795
+ export default {
796
+ port: 3000,
797
+ fetch: app.fetch,
798
+ }
778
799
  ```
779
800
 
780
801
  ## Related projects
package/dist/hono.d.ts CHANGED
@@ -48,7 +48,7 @@ export declare class Hono<E extends Env = Env, P extends string = '/'> extends H
48
48
  private matchRoute;
49
49
  private dispatch;
50
50
  handleEvent(event: FetchEvent): Promise<Response>;
51
- fetch(request: Request, env?: E, executionCtx?: ExecutionContext): Promise<Response>;
51
+ fetch: (request: Request, env?: E | undefined, executionCtx?: ExecutionContext | undefined) => Promise<Response>;
52
52
  request(input: RequestInfo, requestInit?: RequestInit): Promise<Response>;
53
53
  }
54
54
  export {};
package/dist/hono.js CHANGED
@@ -29,6 +29,9 @@ class Hono extends defineDynamicClass() {
29
29
  const message = 'Internal Server Error';
30
30
  return c.text(message, 500);
31
31
  };
32
+ this.fetch = async (request, env, executionCtx) => {
33
+ return this.dispatch(request, executionCtx, env);
34
+ };
32
35
  (0, request_1.extendRequestPrototype)();
33
36
  const allMethods = [...methods, router_1.METHOD_NAME_ALL_LOWERCASE];
34
37
  allMethods.map((method) => {
@@ -117,9 +120,6 @@ class Hono extends defineDynamicClass() {
117
120
  async handleEvent(event) {
118
121
  return this.dispatch(event.request, event);
119
122
  }
120
- async fetch(request, env, executionCtx) {
121
- return this.dispatch(request, executionCtx, env);
122
- }
123
123
  request(input, requestInit) {
124
124
  const req = input instanceof Request ? input : new Request(input, requestInit);
125
125
  return this.dispatch(req);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
4
4
  "description": "Ultrafast web framework for Cloudflare Workers.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",