@hono/node-server 1.11.1 → 1.11.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
@@ -155,7 +155,28 @@ import { serveStatic } from '@hono/node-server/serve-static'
155
155
  app.use('/static/*', serveStatic({ root: './' }))
156
156
  ```
157
157
 
158
- Note that `root` must be _relative_ to the current working directory - absolute paths are not supported.
158
+ Note that `root` must be _relative_ to the current working directory from which the app was started. Absolute paths are not supported.
159
+
160
+ This can cause confusion when running your application locally.
161
+
162
+ Imagine your project structure is:
163
+
164
+ ```
165
+ my-hono-project/
166
+ src/
167
+ index.ts
168
+ static/
169
+ index.html
170
+ ```
171
+
172
+ Typically, you would run your app from the project's root directory (`my-hono-project`),
173
+ so you would need the following code to serve the `static` folder:
174
+
175
+ ```ts
176
+ app.use('/static/*', serveStatic({ root: './static' }))
177
+ ```
178
+
179
+ Notice that `root` here is not relative to `src/index.ts`, rather to `my-hono-project`.
159
180
 
160
181
  ### Options
161
182
 
package/dist/index.js CHANGED
@@ -83,6 +83,16 @@ var newRequestFromIncoming = (method, url, incoming, abortController) => {
83
83
  headers: headerRecord,
84
84
  signal: abortController.signal
85
85
  };
86
+ if (method === "TRACE") {
87
+ init.method = "GET";
88
+ const req = new Request(url, init);
89
+ Object.defineProperty(req, "method", {
90
+ get() {
91
+ return "TRACE";
92
+ }
93
+ });
94
+ return req;
95
+ }
86
96
  if (!(method === "GET" || method === "HEAD")) {
87
97
  init.body = import_node_stream.Readable.toWeb(incoming);
88
98
  }
@@ -423,8 +433,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
423
433
  try {
424
434
  req = newRequest(incoming, options.hostname);
425
435
  outgoing.on("close", () => {
426
- if (incoming.destroyed) {
427
- req[getAbortController]().abort();
436
+ if (incoming.errored) {
437
+ req[getAbortController]().abort(incoming.errored.toString());
428
438
  }
429
439
  });
430
440
  res = fetchCallback(req, { incoming, outgoing });
package/dist/index.mjs CHANGED
@@ -44,6 +44,16 @@ var newRequestFromIncoming = (method, url, incoming, abortController) => {
44
44
  headers: headerRecord,
45
45
  signal: abortController.signal
46
46
  };
47
+ if (method === "TRACE") {
48
+ init.method = "GET";
49
+ const req = new Request(url, init);
50
+ Object.defineProperty(req, "method", {
51
+ get() {
52
+ return "TRACE";
53
+ }
54
+ });
55
+ return req;
56
+ }
47
57
  if (!(method === "GET" || method === "HEAD")) {
48
58
  init.body = Readable.toWeb(incoming);
49
59
  }
@@ -384,8 +394,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
384
394
  try {
385
395
  req = newRequest(incoming, options.hostname);
386
396
  outgoing.on("close", () => {
387
- if (incoming.destroyed) {
388
- req[getAbortController]().abort();
397
+ if (incoming.errored) {
398
+ req[getAbortController]().abort(incoming.errored.toString());
389
399
  }
390
400
  });
391
401
  res = fetchCallback(req, { incoming, outgoing });
package/dist/listener.js CHANGED
@@ -77,6 +77,16 @@ var newRequestFromIncoming = (method, url, incoming, abortController) => {
77
77
  headers: headerRecord,
78
78
  signal: abortController.signal
79
79
  };
80
+ if (method === "TRACE") {
81
+ init.method = "GET";
82
+ const req = new Request(url, init);
83
+ Object.defineProperty(req, "method", {
84
+ get() {
85
+ return "TRACE";
86
+ }
87
+ });
88
+ return req;
89
+ }
80
90
  if (!(method === "GET" || method === "HEAD")) {
81
91
  init.body = import_node_stream.Readable.toWeb(incoming);
82
92
  }
@@ -417,8 +427,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
417
427
  try {
418
428
  req = newRequest(incoming, options.hostname);
419
429
  outgoing.on("close", () => {
420
- if (incoming.destroyed) {
421
- req[getAbortController]().abort();
430
+ if (incoming.errored) {
431
+ req[getAbortController]().abort(incoming.errored.toString());
422
432
  }
423
433
  });
424
434
  res = fetchCallback(req, { incoming, outgoing });
package/dist/listener.mjs CHANGED
@@ -41,6 +41,16 @@ var newRequestFromIncoming = (method, url, incoming, abortController) => {
41
41
  headers: headerRecord,
42
42
  signal: abortController.signal
43
43
  };
44
+ if (method === "TRACE") {
45
+ init.method = "GET";
46
+ const req = new Request(url, init);
47
+ Object.defineProperty(req, "method", {
48
+ get() {
49
+ return "TRACE";
50
+ }
51
+ });
52
+ return req;
53
+ }
44
54
  if (!(method === "GET" || method === "HEAD")) {
45
55
  init.body = Readable.toWeb(incoming);
46
56
  }
@@ -381,8 +391,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
381
391
  try {
382
392
  req = newRequest(incoming, options.hostname);
383
393
  outgoing.on("close", () => {
384
- if (incoming.destroyed) {
385
- req[getAbortController]().abort();
394
+ if (incoming.errored) {
395
+ req[getAbortController]().abort(incoming.errored.toString());
386
396
  }
387
397
  });
388
398
  res = fetchCallback(req, { incoming, outgoing });
package/dist/request.js CHANGED
@@ -70,6 +70,16 @@ var newRequestFromIncoming = (method, url, incoming, abortController) => {
70
70
  headers: headerRecord,
71
71
  signal: abortController.signal
72
72
  };
73
+ if (method === "TRACE") {
74
+ init.method = "GET";
75
+ const req = new Request(url, init);
76
+ Object.defineProperty(req, "method", {
77
+ get() {
78
+ return "TRACE";
79
+ }
80
+ });
81
+ return req;
82
+ }
73
83
  if (!(method === "GET" || method === "HEAD")) {
74
84
  init.body = import_node_stream.Readable.toWeb(incoming);
75
85
  }
package/dist/request.mjs CHANGED
@@ -41,6 +41,16 @@ var newRequestFromIncoming = (method, url, incoming, abortController) => {
41
41
  headers: headerRecord,
42
42
  signal: abortController.signal
43
43
  };
44
+ if (method === "TRACE") {
45
+ init.method = "GET";
46
+ const req = new Request(url, init);
47
+ Object.defineProperty(req, "method", {
48
+ get() {
49
+ return "TRACE";
50
+ }
51
+ });
52
+ return req;
53
+ }
44
54
  if (!(method === "GET" || method === "HEAD")) {
45
55
  init.body = Readable.toWeb(incoming);
46
56
  }
@@ -2,7 +2,7 @@ import { Context, MiddlewareHandler } from 'hono';
2
2
 
3
3
  type ServeStaticOptions = {
4
4
  /**
5
- * Root path, relative to current working directory. (absolute paths are not supported)
5
+ * Root path, relative to current working directory from which the app was started. Absolute paths are not supported.
6
6
  */
7
7
  root?: string;
8
8
  path?: string;
@@ -2,7 +2,7 @@ import { Context, MiddlewareHandler } from 'hono';
2
2
 
3
3
  type ServeStaticOptions = {
4
4
  /**
5
- * Root path, relative to current working directory. (absolute paths are not supported)
5
+ * Root path, relative to current working directory from which the app was started. Absolute paths are not supported.
6
6
  */
7
7
  root?: string;
8
8
  path?: string;
package/dist/server.js CHANGED
@@ -79,6 +79,16 @@ var newRequestFromIncoming = (method, url, incoming, abortController) => {
79
79
  headers: headerRecord,
80
80
  signal: abortController.signal
81
81
  };
82
+ if (method === "TRACE") {
83
+ init.method = "GET";
84
+ const req = new Request(url, init);
85
+ Object.defineProperty(req, "method", {
86
+ get() {
87
+ return "TRACE";
88
+ }
89
+ });
90
+ return req;
91
+ }
82
92
  if (!(method === "GET" || method === "HEAD")) {
83
93
  init.body = import_node_stream.Readable.toWeb(incoming);
84
94
  }
@@ -419,8 +429,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
419
429
  try {
420
430
  req = newRequest(incoming, options.hostname);
421
431
  outgoing.on("close", () => {
422
- if (incoming.destroyed) {
423
- req[getAbortController]().abort();
432
+ if (incoming.errored) {
433
+ req[getAbortController]().abort(incoming.errored.toString());
424
434
  }
425
435
  });
426
436
  res = fetchCallback(req, { incoming, outgoing });
package/dist/server.mjs CHANGED
@@ -44,6 +44,16 @@ var newRequestFromIncoming = (method, url, incoming, abortController) => {
44
44
  headers: headerRecord,
45
45
  signal: abortController.signal
46
46
  };
47
+ if (method === "TRACE") {
48
+ init.method = "GET";
49
+ const req = new Request(url, init);
50
+ Object.defineProperty(req, "method", {
51
+ get() {
52
+ return "TRACE";
53
+ }
54
+ });
55
+ return req;
56
+ }
47
57
  if (!(method === "GET" || method === "HEAD")) {
48
58
  init.body = Readable.toWeb(incoming);
49
59
  }
@@ -384,8 +394,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
384
394
  try {
385
395
  req = newRequest(incoming, options.hostname);
386
396
  outgoing.on("close", () => {
387
- if (incoming.destroyed) {
388
- req[getAbortController]().abort();
397
+ if (incoming.errored) {
398
+ req[getAbortController]().abort(incoming.errored.toString());
389
399
  }
390
400
  });
391
401
  res = fetchCallback(req, { incoming, outgoing });
package/dist/vercel.js CHANGED
@@ -77,6 +77,16 @@ var newRequestFromIncoming = (method, url, incoming, abortController) => {
77
77
  headers: headerRecord,
78
78
  signal: abortController.signal
79
79
  };
80
+ if (method === "TRACE") {
81
+ init.method = "GET";
82
+ const req = new Request(url, init);
83
+ Object.defineProperty(req, "method", {
84
+ get() {
85
+ return "TRACE";
86
+ }
87
+ });
88
+ return req;
89
+ }
80
90
  if (!(method === "GET" || method === "HEAD")) {
81
91
  init.body = import_node_stream.Readable.toWeb(incoming);
82
92
  }
@@ -417,8 +427,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
417
427
  try {
418
428
  req = newRequest(incoming, options.hostname);
419
429
  outgoing.on("close", () => {
420
- if (incoming.destroyed) {
421
- req[getAbortController]().abort();
430
+ if (incoming.errored) {
431
+ req[getAbortController]().abort(incoming.errored.toString());
422
432
  }
423
433
  });
424
434
  res = fetchCallback(req, { incoming, outgoing });
package/dist/vercel.mjs CHANGED
@@ -41,6 +41,16 @@ var newRequestFromIncoming = (method, url, incoming, abortController) => {
41
41
  headers: headerRecord,
42
42
  signal: abortController.signal
43
43
  };
44
+ if (method === "TRACE") {
45
+ init.method = "GET";
46
+ const req = new Request(url, init);
47
+ Object.defineProperty(req, "method", {
48
+ get() {
49
+ return "TRACE";
50
+ }
51
+ });
52
+ return req;
53
+ }
44
54
  if (!(method === "GET" || method === "HEAD")) {
45
55
  init.body = Readable.toWeb(incoming);
46
56
  }
@@ -381,8 +391,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
381
391
  try {
382
392
  req = newRequest(incoming, options.hostname);
383
393
  outgoing.on("close", () => {
384
- if (incoming.destroyed) {
385
- req[getAbortController]().abort();
394
+ if (incoming.errored) {
395
+ req[getAbortController]().abort(incoming.errored.toString());
386
396
  }
387
397
  });
388
398
  res = fetchCallback(req, { incoming, outgoing });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hono/node-server",
3
- "version": "1.11.1",
3
+ "version": "1.11.3",
4
4
  "description": "Node.js Adapter for Hono",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -46,7 +46,7 @@
46
46
  }
47
47
  },
48
48
  "scripts": {
49
- "test": "jest",
49
+ "test": "node --expose-gc ./node_modules/.bin/jest",
50
50
  "build": "tsup",
51
51
  "watch": "tsup --watch",
52
52
  "postbuild": "publint",