hono 3.0.0-rc.8 → 3.0.0

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.
Files changed (84) hide show
  1. package/README.md +23 -19
  2. package/dist/adapter/bun/serve-static.js +1 -1
  3. package/dist/adapter/cloudflare-pages/handler.js +3 -6
  4. package/dist/adapter/cloudflare-workers/serve-static.js +1 -1
  5. package/dist/adapter/deno/index.js +5 -0
  6. package/dist/adapter/deno/serve-static.js +1 -1
  7. package/dist/adapter/nextjs/handler.js +2 -5
  8. package/dist/cjs/adapter/bun/serve-static.js +1 -1
  9. package/dist/cjs/adapter/cloudflare-pages/handler.js +3 -6
  10. package/dist/cjs/adapter/cloudflare-workers/serve-static.js +1 -1
  11. package/dist/cjs/{router/static-router → adapter/deno}/index.js +6 -6
  12. package/dist/cjs/adapter/deno/serve-static.js +1 -1
  13. package/dist/cjs/adapter/nextjs/handler.js +2 -5
  14. package/dist/cjs/client/client.js +122 -0
  15. package/dist/cjs/client/index.js +28 -0
  16. package/dist/cjs/client/types.js +16 -0
  17. package/dist/cjs/client/utils.js +52 -0
  18. package/dist/cjs/compose.js +1 -1
  19. package/dist/cjs/context.js +11 -8
  20. package/dist/cjs/hono.js +45 -45
  21. package/dist/cjs/{utils/http-exception.js → http-exception.js} +2 -3
  22. package/dist/cjs/middleware/basic-auth/index.js +1 -1
  23. package/dist/cjs/middleware/bearer-auth/index.js +1 -1
  24. package/dist/cjs/middleware/jwt/index.js +1 -1
  25. package/dist/cjs/middleware/logger/index.js +1 -1
  26. package/dist/cjs/request.js +34 -47
  27. package/dist/cjs/router/reg-exp-router/node.js +12 -3
  28. package/dist/cjs/router/reg-exp-router/router.js +23 -7
  29. package/dist/cjs/router/reg-exp-router/trie.js +5 -2
  30. package/dist/cjs/utils/mime.js +25 -5
  31. package/dist/cjs/utils/url.js +13 -12
  32. package/dist/cjs/validator/index.js +28 -0
  33. package/dist/cjs/{middleware/validator/index.js → validator/validator.js} +3 -6
  34. package/dist/client/client.js +99 -0
  35. package/dist/client/index.js +5 -0
  36. package/dist/client/types.js +0 -0
  37. package/dist/client/utils.js +27 -0
  38. package/dist/compose.js +1 -1
  39. package/dist/context.js +11 -8
  40. package/dist/hono.js +45 -45
  41. package/dist/{utils/http-exception.js → http-exception.js} +3 -4
  42. package/dist/middleware/basic-auth/index.js +1 -1
  43. package/dist/middleware/bearer-auth/index.js +1 -1
  44. package/dist/middleware/jwt/index.js +1 -1
  45. package/dist/middleware/logger/index.js +1 -1
  46. package/dist/request.js +34 -47
  47. package/dist/router/reg-exp-router/node.js +12 -3
  48. package/dist/router/reg-exp-router/router.js +23 -7
  49. package/dist/router/reg-exp-router/trie.js +5 -2
  50. package/dist/types/adapter/cloudflare-pages/handler.d.ts +15 -3
  51. package/dist/types/adapter/deno/index.d.ts +1 -0
  52. package/dist/types/adapter/nextjs/handler.d.ts +6 -2
  53. package/dist/types/client/client.d.ts +4 -0
  54. package/dist/types/client/index.d.ts +2 -0
  55. package/dist/types/client/types.d.ts +37 -0
  56. package/dist/types/client/utils.d.ts +3 -0
  57. package/dist/types/compose.d.ts +1 -1
  58. package/dist/types/context.d.ts +7 -9
  59. package/dist/types/hono.d.ts +18 -27
  60. package/dist/types/{utils/http-exception.d.ts → http-exception.d.ts} +1 -1
  61. package/dist/types/index.d.ts +1 -3
  62. package/dist/types/middleware/jsx/index.d.ts +2 -1
  63. package/dist/types/request.d.ts +14 -15
  64. package/dist/types/router/reg-exp-router/node.d.ts +1 -1
  65. package/dist/types/router/reg-exp-router/trie.d.ts +1 -1
  66. package/dist/types/types.d.ts +70 -67
  67. package/dist/types/utils/types.d.ts +1 -0
  68. package/dist/types/utils/url.d.ts +2 -2
  69. package/dist/types/validator/index.d.ts +1 -0
  70. package/dist/types/validator/validator.d.ts +6 -0
  71. package/dist/utils/mime.js +25 -5
  72. package/dist/utils/url.js +13 -12
  73. package/dist/validator/index.js +5 -0
  74. package/dist/{middleware/validator/index.js → validator/validator.js} +4 -7
  75. package/package.json +34 -24
  76. package/dist/cjs/router/static-router/router.js +0 -98
  77. package/dist/cjs/utils/object.js +0 -58
  78. package/dist/router/static-router/index.js +0 -5
  79. package/dist/router/static-router/router.js +0 -75
  80. package/dist/types/middleware/validator/index.d.ts +0 -9
  81. package/dist/types/router/static-router/index.d.ts +0 -1
  82. package/dist/types/router/static-router/router.d.ts +0 -9
  83. package/dist/types/utils/object.d.ts +0 -2
  84. package/dist/utils/object.js +0 -34
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <a href="https://honojs.dev">
2
+ <a href="https://hono.dev">
3
3
  <img src="https://raw.githubusercontent.com/honojs/hono/main/docs/images/hono-title.png" width="500" height="auto" alt="Hono"/>
4
4
  </a>
5
5
  </div>
@@ -7,8 +7,8 @@
7
7
  <hr />
8
8
 
9
9
  <p align="center">
10
- <a href="https://honojs.dev"><b>Documentation :point_right: honojs.dev</b></a><br />
11
- <i>v2.x has been released!</i> <a href="docs/MIGRATION.md">Migration guide</b>
10
+ <a href="https://hono.dev"><b>Documentation :point_right: hono.dev</b></a><br />
11
+ <i>v3 has been released!</i> <a href="docs/MIGRATION.md">Migration guide</b>
12
12
  </p>
13
13
 
14
14
  <hr />
@@ -17,51 +17,55 @@
17
17
  [![GitHub](https://img.shields.io/github/license/honojs/hono)](https://github.com/honojs/hono/blob/main/LICENSE)
18
18
  [![npm](https://img.shields.io/npm/v/hono)](https://www.npmjs.com/package/hono)
19
19
  [![npm](https://img.shields.io/npm/dm/hono)](https://www.npmjs.com/package/hono)
20
+ [![Bundle Size](https://img.shields.io/bundlephobia/min/hono)](https://bundlephobia.com/result?p=hono)
21
+ [![Bundle Size](https://img.shields.io/bundlephobia/minzip/hono)](https://bundlephobia.com/result?p=hono)
20
22
  [![npm type definitions](https://img.shields.io/npm/types/hono)](https://www.npmjs.com/package/hono)
21
23
  [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/honojs/hono)](https://github.com/honojs/hono/pulse)
22
24
  [![GitHub last commit](https://img.shields.io/github/last-commit/honojs/hono)](https://github.com/honojs/hono/commits/main)
23
25
  [![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)
24
26
  [![Discord badge](https://img.shields.io/discord/1011308539819597844?label=Discord&logo=Discord)](https://discord.gg/KMh2eNSdxV)
25
27
 
26
- Hono - _**[] means flame🔥 in Japanese**_ - is a small, simple, and ultrafast web framework for Cloudflare Workers, Deno, Bun, and others.
28
+ Hono - _**\[炎\] means flame🔥 in Japanese**_ - is a small, simple, and ultrafast web framework for the Edge.
29
+ It works on Cloudflare Workers, Fastly Compute@Edge, Deno, Bun, Vercel, Lagon, Node.js, and others.
30
+ Fast, but not only fast.
27
31
 
28
32
  ```ts
29
33
  import { Hono } from 'hono'
30
34
  const app = new Hono()
31
35
 
32
- app.get('/', (c) => c.text('Hono!!'))
36
+ app.get('/', (c) => c.text('Hono!'))
33
37
 
34
38
  export default app
35
39
  ```
36
40
 
37
41
  ## Features
38
42
 
39
- - **Ultrafast** - The routers are really smart. Not using linear loops. The fastest one will be selected from three routers.
40
- - **Zero-dependencies** - Using only Web Standard API. Does not depend on other npm or Deno libraries.
41
- - **Middleware** - Hono has built-in middleware, custom middleware, and third-party middleware. Batteries included.
42
- - **TypeScript** - First-class TypeScript support. Now, we've got "Types".
43
- - **Multi-runtime** - Works on Cloudflare Workers, Fastly Compute@Edge, Deno, Bun, or Node.js. The same code runs on all platforms.
43
+ - **Ultrafast** - The routers are really fast and smart. Not using linear loops. Fast.
44
+ - **Multi-runtime** - Works on Cloudflare Workers, Fastly Compute@Edge, Deno, Bun, Lagon, or Node.js. The same code runs on all platforms.
45
+ - **Batteries Included** - Hono has built-in middleware, custom middleware, and third-party middleware. Batteries included.
46
+ - **Fine DX** - First-class TypeScript support. Now, we've got "Types".
47
+ - **Small** - About 20kB. Zero-dependencies. Using only Web Standard API.
44
48
 
45
49
  ## Benchmarks
46
50
 
47
- **Hono is fastest**, compared to other routers for Cloudflare Workers.
51
+ **Hono is the fastest**, compared to other routers for Cloudflare Workers.
48
52
 
49
- ```plain
50
- Hono x 616,464 ops/sec ±4.76% (83 runs sampled)
51
- itty-router x 203,074 ops/sec ±3.66% (88 runs sampled)
52
- sunder x 314,306 ops/sec ±2.28% (87 runs sampled)
53
- worktop x 194,111 ops/sec ±2.78% (81 runs sampled)
53
+ ```
54
+ Hono x 385,807 ops/sec ±5.02% (76 runs sampled)
55
+ itty-router x 205,318 ops/sec ±3.63% (84 runs sampled)
56
+ sunder x 287,198 ops/sec ±4.90% (74 runs sampled)
57
+ worktop x 191,134 ops/sec ±3.06% (85 runs sampled)
54
58
  Fastest is Hono
55
- ✨ Done in 30.77s.
59
+ ✨ Done in 27.51s.
56
60
  ```
57
61
 
58
62
  ## Documentation
59
63
 
60
- The documentation is available on [honojs.dev](https://honojs.dev).
64
+ The documentation is available on [hono.dev](https://hono.dev).
61
65
 
62
66
  ## Migration
63
67
 
64
- Migration guide is available on [docs/MIGRATION.md](docs/MIGRATION.md).
68
+ The migration guide is available on [docs/MIGRATION.md](docs/MIGRATION.md).
65
69
 
66
70
  ## Communication
67
71
 
@@ -12,7 +12,7 @@ var serveStatic = (options = { root: "" }) => {
12
12
  }
13
13
  const url = new URL(c.req.url);
14
14
  let path = getFilePath({
15
- filename: options.path ?? url.pathname,
15
+ filename: options.path ?? decodeURI(url.pathname),
16
16
  root: options.root,
17
17
  defaultDocument: DEFAULT_DOCUMENT
18
18
  });
@@ -1,10 +1,7 @@
1
1
  // src/adapter/cloudflare-pages/handler.ts
2
- var handle = (app) => {
3
- return (eventContext) => {
4
- const { request, env, waitUntil, passThroughOnException } = eventContext;
5
- return app.fetch(request, env, { waitUntil, passThroughOnException });
6
- };
7
- };
2
+ import { Hono } from "../../hono.js";
3
+ var handle = (subApp, path = "/") => ({ request, env, waitUntil }) => new Hono().route(path, subApp).fetch(request, env, { waitUntil, passThroughOnException: () => {
4
+ } });
8
5
  export {
9
6
  handle
10
7
  };
@@ -11,7 +11,7 @@ var serveStatic = (options = { root: "" }) => {
11
11
  }
12
12
  const url = new URL(c.req.url);
13
13
  const path = getFilePath({
14
- filename: options.path ?? url.pathname,
14
+ filename: options.path ?? decodeURI(url.pathname),
15
15
  root: options.root,
16
16
  defaultDocument: DEFAULT_DOCUMENT
17
17
  });
@@ -0,0 +1,5 @@
1
+ // src/adapter/deno/index.ts
2
+ import { serveStatic } from "./serve-static.js";
3
+ export {
4
+ serveStatic
5
+ };
@@ -10,7 +10,7 @@ var serveStatic = (options = { root: "" }) => {
10
10
  }
11
11
  const url = new URL(c.req.url);
12
12
  let path = getFilePath({
13
- filename: options.path ?? url.pathname,
13
+ filename: options.path ?? decodeURI(url.pathname),
14
14
  root: options.root,
15
15
  defaultDocument: DEFAULT_DOCUMENT
16
16
  });
@@ -1,9 +1,6 @@
1
1
  // src/adapter/nextjs/handler.ts
2
- var handle = (app) => {
3
- return async (req) => {
4
- return app.fetch(req);
5
- };
6
- };
2
+ import { Hono } from "../../hono.js";
3
+ var handle = (subApp, path = "/") => async (req) => new Hono().route(path, subApp).fetch(req);
7
4
  export {
8
5
  handle
9
6
  };
@@ -34,7 +34,7 @@ const serveStatic = (options = { root: "" }) => {
34
34
  }
35
35
  const url = new URL(c.req.url);
36
36
  let path = (0, import_filepath.getFilePath)({
37
- filename: options.path ?? url.pathname,
37
+ filename: options.path ?? decodeURI(url.pathname),
38
38
  root: options.root,
39
39
  defaultDocument: DEFAULT_DOCUMENT
40
40
  });
@@ -21,12 +21,9 @@ __export(handler_exports, {
21
21
  handle: () => handle
22
22
  });
23
23
  module.exports = __toCommonJS(handler_exports);
24
- const handle = (app) => {
25
- return (eventContext) => {
26
- const { request, env, waitUntil, passThroughOnException } = eventContext;
27
- return app.fetch(request, env, { waitUntil, passThroughOnException });
28
- };
29
- };
24
+ var import_hono = require("../../hono");
25
+ const handle = (subApp, path = "/") => ({ request, env, waitUntil }) => new import_hono.Hono().route(path, subApp).fetch(request, env, { waitUntil, passThroughOnException: () => {
26
+ } });
30
27
  // Annotate the CommonJS export names for ESM import in node:
31
28
  0 && (module.exports = {
32
29
  handle
@@ -33,7 +33,7 @@ const serveStatic = (options = { root: "" }) => {
33
33
  }
34
34
  const url = new URL(c.req.url);
35
35
  const path = (0, import_filepath.getFilePath)({
36
- filename: options.path ?? url.pathname,
36
+ filename: options.path ?? decodeURI(url.pathname),
37
37
  root: options.root,
38
38
  defaultDocument: DEFAULT_DOCUMENT
39
39
  });
@@ -16,13 +16,13 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var static_router_exports = {};
20
- __export(static_router_exports, {
21
- StaticRouter: () => import_router.StaticRouter
19
+ var deno_exports = {};
20
+ __export(deno_exports, {
21
+ serveStatic: () => import_serve_static.serveStatic
22
22
  });
23
- module.exports = __toCommonJS(static_router_exports);
24
- var import_router = require("./router");
23
+ module.exports = __toCommonJS(deno_exports);
24
+ var import_serve_static = require("./serve-static");
25
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
- StaticRouter
27
+ serveStatic
28
28
  });
@@ -32,7 +32,7 @@ const serveStatic = (options = { root: "" }) => {
32
32
  }
33
33
  const url = new URL(c.req.url);
34
34
  let path = (0, import_filepath.getFilePath)({
35
- filename: options.path ?? url.pathname,
35
+ filename: options.path ?? decodeURI(url.pathname),
36
36
  root: options.root,
37
37
  defaultDocument: DEFAULT_DOCUMENT
38
38
  });
@@ -21,11 +21,8 @@ __export(handler_exports, {
21
21
  handle: () => handle
22
22
  });
23
23
  module.exports = __toCommonJS(handler_exports);
24
- const handle = (app) => {
25
- return async (req) => {
26
- return app.fetch(req);
27
- };
28
- };
24
+ var import_hono = require("../../hono");
25
+ const handle = (subApp, path = "/") => async (req) => new import_hono.Hono().route(path, subApp).fetch(req);
29
26
  // Annotate the CommonJS export names for ESM import in node:
30
27
  0 && (module.exports = {
31
28
  handle
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var client_exports = {};
20
+ __export(client_exports, {
21
+ hc: () => hc
22
+ });
23
+ module.exports = __toCommonJS(client_exports);
24
+ var import_utils = require("./utils");
25
+ const createProxy = (callback, path) => {
26
+ const proxy = new Proxy(() => {
27
+ }, {
28
+ get(_obj, key) {
29
+ if (typeof key !== "string")
30
+ return void 0;
31
+ return createProxy(callback, [...path, key]);
32
+ },
33
+ apply(_1, _2, args) {
34
+ return callback({
35
+ path,
36
+ args
37
+ });
38
+ }
39
+ });
40
+ return proxy;
41
+ };
42
+ class ClientRequestImpl {
43
+ constructor(url, method) {
44
+ this.queryParams = void 0;
45
+ this.pathParams = {};
46
+ this.cType = void 0;
47
+ this.fetch = (args, opt) => {
48
+ if (args) {
49
+ if (args.query) {
50
+ for (const [k, v] of Object.entries(args.query)) {
51
+ this.queryParams || (this.queryParams = new URLSearchParams());
52
+ this.queryParams.set(k, v);
53
+ }
54
+ }
55
+ if (args.queries) {
56
+ for (const [k, v] of Object.entries(args.queries)) {
57
+ for (const v2 of v) {
58
+ this.queryParams || (this.queryParams = new URLSearchParams());
59
+ this.queryParams.append(k, v2);
60
+ }
61
+ }
62
+ }
63
+ if (args.form) {
64
+ const form = new FormData();
65
+ for (const [k, v] of Object.entries(args.form)) {
66
+ form.append(k, v);
67
+ }
68
+ this.rBody = form;
69
+ }
70
+ if (args.json) {
71
+ this.rBody = JSON.stringify(args.json);
72
+ this.cType = "application/json";
73
+ }
74
+ if (args.param) {
75
+ this.pathParams = args.param;
76
+ }
77
+ }
78
+ let methodUpperCase = this.method.toUpperCase();
79
+ let setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
80
+ const headerValues = opt?.headers ? opt.headers : {};
81
+ if (this.cType)
82
+ headerValues["Content-Type"] = this.cType;
83
+ const headers = new Headers(headerValues ?? void 0);
84
+ let url = this.url;
85
+ url = (0, import_utils.removeIndexString)(url);
86
+ url = (0, import_utils.replaceUrlParam)(url, this.pathParams);
87
+ if (this.queryParams) {
88
+ url = url + "?" + this.queryParams.toString();
89
+ }
90
+ methodUpperCase = this.method.toUpperCase();
91
+ setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
92
+ return fetch(url, {
93
+ body: setBody ? this.rBody : void 0,
94
+ method: methodUpperCase,
95
+ headers
96
+ });
97
+ };
98
+ this.url = url;
99
+ this.method = method;
100
+ }
101
+ }
102
+ const hc = (baseUrl) => createProxy(async (opts) => {
103
+ const parts = [...opts.path];
104
+ let method = "";
105
+ if (/^\$/.test(parts[parts.length - 1])) {
106
+ const last = parts.pop();
107
+ if (last) {
108
+ method = last.replace(/^\$/, "");
109
+ }
110
+ }
111
+ const path = parts.join("/");
112
+ const url = (0, import_utils.mergePath)(baseUrl, path);
113
+ const req = new ClientRequestImpl(url, method);
114
+ if (method) {
115
+ return req.fetch(opts.args[0], opts.args[1]);
116
+ }
117
+ return req;
118
+ }, []);
119
+ // Annotate the CommonJS export names for ESM import in node:
120
+ 0 && (module.exports = {
121
+ hc
122
+ });
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var client_exports = {};
20
+ __export(client_exports, {
21
+ hc: () => import_client.hc
22
+ });
23
+ module.exports = __toCommonJS(client_exports);
24
+ var import_client = require("./client");
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ hc
28
+ });
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var utils_exports = {};
20
+ __export(utils_exports, {
21
+ mergePath: () => mergePath,
22
+ removeIndexString: () => removeIndexString,
23
+ replaceUrlParam: () => replaceUrlParam
24
+ });
25
+ module.exports = __toCommonJS(utils_exports);
26
+ var import_url = require("../utils/url");
27
+ const mergePath = (base, path) => {
28
+ base = base.replace(/\/+$/, "");
29
+ base = base + "/";
30
+ path = path.replace(/^\/+/, "");
31
+ return base + path;
32
+ };
33
+ const replaceUrlParam = (urlString, params) => {
34
+ for (const [k, v] of Object.entries(params)) {
35
+ const reg = new RegExp("/:" + k);
36
+ urlString = urlString.replace(reg, `/${v}`);
37
+ }
38
+ return urlString;
39
+ };
40
+ const removeIndexString = (urlSting) => {
41
+ const path = (0, import_url.getPathFromURL)(urlSting);
42
+ if (path === "/index") {
43
+ return urlSting.replace(/index$/, "");
44
+ }
45
+ return urlSting;
46
+ };
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ mergePath,
50
+ removeIndexString,
51
+ replaceUrlParam
52
+ });
@@ -22,7 +22,7 @@ __export(compose_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(compose_exports);
24
24
  var import_context = require("./context");
25
- const compose = (middleware, onNotFound, onError) => {
25
+ const compose = (middleware, onError, onNotFound) => {
26
26
  const middlewareLength = middleware.length;
27
27
  return (context, next) => {
28
28
  let index = -1;
@@ -160,18 +160,15 @@ class Context {
160
160
  if (options.notFoundHandler) {
161
161
  this.notFoundHandler = options.notFoundHandler;
162
162
  }
163
- this._queryIndex = options.queryIndex;
164
163
  }
165
164
  }
166
165
  get req() {
167
166
  if (this._req) {
168
167
  return this._req;
169
168
  } else {
170
- this._req = new import_request.HonoRequest(this.rawRequest, this._paramData, this._queryIndex);
171
- this.rawRequest = null;
172
- delete this.rawRequest;
173
- this._paramData = null;
174
- delete this._paramData;
169
+ this._req = new import_request.HonoRequest(this.rawRequest, this._paramData);
170
+ this.rawRequest = void 0;
171
+ this._paramData = void 0;
175
172
  return this._req;
176
173
  }
177
174
  }
@@ -193,6 +190,12 @@ class Context {
193
190
  return this._res || (this._res = new Response("404 Not Found", { status: 404 }));
194
191
  }
195
192
  set res(_res) {
193
+ if (this._res) {
194
+ this._res.headers.delete("content-type");
195
+ this._res.headers.forEach((v, k) => {
196
+ _res.headers.set(k, v);
197
+ });
198
+ }
196
199
  this._res = _res;
197
200
  this.finalized = true;
198
201
  }
@@ -205,10 +208,10 @@ class Context {
205
208
  return "bun";
206
209
  }
207
210
  if (typeof global?.WebSocketPair === "function") {
208
- return "cloudflare";
211
+ return "workerd";
209
212
  }
210
213
  if (typeof global?.EdgeRuntime === "string") {
211
- return "vercel";
214
+ return "edge-light";
212
215
  }
213
216
  let onFastly = false;
214
217
  try {