@hono/node-server 1.11.0 → 1.11.2

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/index.js CHANGED
@@ -61,7 +61,7 @@ var Request = class extends GlobalRequest {
61
61
  if (typeof input === "object" && getRequestCache in input) {
62
62
  input = input[getRequestCache]();
63
63
  }
64
- if (options?.body instanceof ReadableStream) {
64
+ if (typeof options?.body?.getReader !== "undefined") {
65
65
  ;
66
66
  options.duplex ??= "half";
67
67
  }
@@ -244,7 +244,7 @@ var Response2 = class _Response {
244
244
  } else {
245
245
  this.#init = init;
246
246
  }
247
- if (typeof body === "string" || body instanceof ReadableStream) {
247
+ if (typeof body === "string" || typeof body?.getReader !== "undefined") {
248
248
  let headers = init?.headers || { "content-type": "text/plain; charset=UTF-8" };
249
249
  if (headers instanceof Headers) {
250
250
  headers = buildOutgoingHttpHeaders(headers);
@@ -423,8 +423,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
423
423
  try {
424
424
  req = newRequest(incoming, options.hostname);
425
425
  outgoing.on("close", () => {
426
- if (incoming.destroyed) {
427
- req[getAbortController]().abort();
426
+ if (incoming.errored) {
427
+ req[getAbortController]().abort(incoming.errored.toString());
428
428
  }
429
429
  });
430
430
  res = fetchCallback(req, { incoming, outgoing });
package/dist/index.mjs CHANGED
@@ -22,7 +22,7 @@ var Request = class extends GlobalRequest {
22
22
  if (typeof input === "object" && getRequestCache in input) {
23
23
  input = input[getRequestCache]();
24
24
  }
25
- if (options?.body instanceof ReadableStream) {
25
+ if (typeof options?.body?.getReader !== "undefined") {
26
26
  ;
27
27
  options.duplex ??= "half";
28
28
  }
@@ -205,7 +205,7 @@ var Response2 = class _Response {
205
205
  } else {
206
206
  this.#init = init;
207
207
  }
208
- if (typeof body === "string" || body instanceof ReadableStream) {
208
+ if (typeof body === "string" || typeof body?.getReader !== "undefined") {
209
209
  let headers = init?.headers || { "content-type": "text/plain; charset=UTF-8" };
210
210
  if (headers instanceof Headers) {
211
211
  headers = buildOutgoingHttpHeaders(headers);
@@ -384,8 +384,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
384
384
  try {
385
385
  req = newRequest(incoming, options.hostname);
386
386
  outgoing.on("close", () => {
387
- if (incoming.destroyed) {
388
- req[getAbortController]().abort();
387
+ if (incoming.errored) {
388
+ req[getAbortController]().abort(incoming.errored.toString());
389
389
  }
390
390
  });
391
391
  res = fetchCallback(req, { incoming, outgoing });
package/dist/listener.js CHANGED
@@ -55,7 +55,7 @@ var Request = class extends GlobalRequest {
55
55
  if (typeof input === "object" && getRequestCache in input) {
56
56
  input = input[getRequestCache]();
57
57
  }
58
- if (options?.body instanceof ReadableStream) {
58
+ if (typeof options?.body?.getReader !== "undefined") {
59
59
  ;
60
60
  options.duplex ??= "half";
61
61
  }
@@ -238,7 +238,7 @@ var Response2 = class _Response {
238
238
  } else {
239
239
  this.#init = init;
240
240
  }
241
- if (typeof body === "string" || body instanceof ReadableStream) {
241
+ if (typeof body === "string" || typeof body?.getReader !== "undefined") {
242
242
  let headers = init?.headers || { "content-type": "text/plain; charset=UTF-8" };
243
243
  if (headers instanceof Headers) {
244
244
  headers = buildOutgoingHttpHeaders(headers);
@@ -417,8 +417,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
417
417
  try {
418
418
  req = newRequest(incoming, options.hostname);
419
419
  outgoing.on("close", () => {
420
- if (incoming.destroyed) {
421
- req[getAbortController]().abort();
420
+ if (incoming.errored) {
421
+ req[getAbortController]().abort(incoming.errored.toString());
422
422
  }
423
423
  });
424
424
  res = fetchCallback(req, { incoming, outgoing });
package/dist/listener.mjs CHANGED
@@ -19,7 +19,7 @@ var Request = class extends GlobalRequest {
19
19
  if (typeof input === "object" && getRequestCache in input) {
20
20
  input = input[getRequestCache]();
21
21
  }
22
- if (options?.body instanceof ReadableStream) {
22
+ if (typeof options?.body?.getReader !== "undefined") {
23
23
  ;
24
24
  options.duplex ??= "half";
25
25
  }
@@ -202,7 +202,7 @@ var Response2 = class _Response {
202
202
  } else {
203
203
  this.#init = init;
204
204
  }
205
- if (typeof body === "string" || body instanceof ReadableStream) {
205
+ if (typeof body === "string" || typeof body?.getReader !== "undefined") {
206
206
  let headers = init?.headers || { "content-type": "text/plain; charset=UTF-8" };
207
207
  if (headers instanceof Headers) {
208
208
  headers = buildOutgoingHttpHeaders(headers);
@@ -381,8 +381,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
381
381
  try {
382
382
  req = newRequest(incoming, options.hostname);
383
383
  outgoing.on("close", () => {
384
- if (incoming.destroyed) {
385
- req[getAbortController]().abort();
384
+ if (incoming.errored) {
385
+ req[getAbortController]().abort(incoming.errored.toString());
386
386
  }
387
387
  });
388
388
  res = fetchCallback(req, { incoming, outgoing });
package/dist/request.js CHANGED
@@ -48,7 +48,7 @@ var Request = class extends GlobalRequest {
48
48
  if (typeof input === "object" && getRequestCache in input) {
49
49
  input = input[getRequestCache]();
50
50
  }
51
- if (options?.body instanceof ReadableStream) {
51
+ if (typeof options?.body?.getReader !== "undefined") {
52
52
  ;
53
53
  options.duplex ??= "half";
54
54
  }
package/dist/request.mjs CHANGED
@@ -19,7 +19,7 @@ var Request = class extends GlobalRequest {
19
19
  if (typeof input === "object" && getRequestCache in input) {
20
20
  input = input[getRequestCache]();
21
21
  }
22
- if (options?.body instanceof ReadableStream) {
22
+ if (typeof options?.body?.getReader !== "undefined") {
23
23
  ;
24
24
  options.duplex ??= "half";
25
25
  }
package/dist/response.js CHANGED
@@ -71,7 +71,7 @@ var Response = class _Response {
71
71
  } else {
72
72
  this.#init = init;
73
73
  }
74
- if (typeof body === "string" || body instanceof ReadableStream) {
74
+ if (typeof body === "string" || typeof body?.getReader !== "undefined") {
75
75
  let headers = init?.headers || { "content-type": "text/plain; charset=UTF-8" };
76
76
  if (headers instanceof Headers) {
77
77
  headers = buildOutgoingHttpHeaders(headers);
package/dist/response.mjs CHANGED
@@ -42,7 +42,7 @@ var Response = class _Response {
42
42
  } else {
43
43
  this.#init = init;
44
44
  }
45
- if (typeof body === "string" || body instanceof ReadableStream) {
45
+ if (typeof body === "string" || typeof body?.getReader !== "undefined") {
46
46
  let headers = init?.headers || { "content-type": "text/plain; charset=UTF-8" };
47
47
  if (headers instanceof Headers) {
48
48
  headers = buildOutgoingHttpHeaders(headers);
@@ -139,8 +139,7 @@ var serveStatic = (options = { root: "" }) => {
139
139
  if (c.finalized) {
140
140
  return next();
141
141
  }
142
- const url = new URL(c.req.url);
143
- const filename = options.path ?? decodeURIComponent(url.pathname);
142
+ const filename = options.path ?? decodeURIComponent(c.req.path);
144
143
  let path = getFilePath({
145
144
  filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
146
145
  root: options.root,
@@ -115,8 +115,7 @@ var serveStatic = (options = { root: "" }) => {
115
115
  if (c.finalized) {
116
116
  return next();
117
117
  }
118
- const url = new URL(c.req.url);
119
- const filename = options.path ?? decodeURIComponent(url.pathname);
118
+ const filename = options.path ?? decodeURIComponent(c.req.path);
120
119
  let path = getFilePath({
121
120
  filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
122
121
  root: options.root,
package/dist/server.js CHANGED
@@ -57,7 +57,7 @@ var Request = class extends GlobalRequest {
57
57
  if (typeof input === "object" && getRequestCache in input) {
58
58
  input = input[getRequestCache]();
59
59
  }
60
- if (options?.body instanceof ReadableStream) {
60
+ if (typeof options?.body?.getReader !== "undefined") {
61
61
  ;
62
62
  options.duplex ??= "half";
63
63
  }
@@ -240,7 +240,7 @@ var Response2 = class _Response {
240
240
  } else {
241
241
  this.#init = init;
242
242
  }
243
- if (typeof body === "string" || body instanceof ReadableStream) {
243
+ if (typeof body === "string" || typeof body?.getReader !== "undefined") {
244
244
  let headers = init?.headers || { "content-type": "text/plain; charset=UTF-8" };
245
245
  if (headers instanceof Headers) {
246
246
  headers = buildOutgoingHttpHeaders(headers);
@@ -419,8 +419,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
419
419
  try {
420
420
  req = newRequest(incoming, options.hostname);
421
421
  outgoing.on("close", () => {
422
- if (incoming.destroyed) {
423
- req[getAbortController]().abort();
422
+ if (incoming.errored) {
423
+ req[getAbortController]().abort(incoming.errored.toString());
424
424
  }
425
425
  });
426
426
  res = fetchCallback(req, { incoming, outgoing });
package/dist/server.mjs CHANGED
@@ -22,7 +22,7 @@ var Request = class extends GlobalRequest {
22
22
  if (typeof input === "object" && getRequestCache in input) {
23
23
  input = input[getRequestCache]();
24
24
  }
25
- if (options?.body instanceof ReadableStream) {
25
+ if (typeof options?.body?.getReader !== "undefined") {
26
26
  ;
27
27
  options.duplex ??= "half";
28
28
  }
@@ -205,7 +205,7 @@ var Response2 = class _Response {
205
205
  } else {
206
206
  this.#init = init;
207
207
  }
208
- if (typeof body === "string" || body instanceof ReadableStream) {
208
+ if (typeof body === "string" || typeof body?.getReader !== "undefined") {
209
209
  let headers = init?.headers || { "content-type": "text/plain; charset=UTF-8" };
210
210
  if (headers instanceof Headers) {
211
211
  headers = buildOutgoingHttpHeaders(headers);
@@ -384,8 +384,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
384
384
  try {
385
385
  req = newRequest(incoming, options.hostname);
386
386
  outgoing.on("close", () => {
387
- if (incoming.destroyed) {
388
- req[getAbortController]().abort();
387
+ if (incoming.errored) {
388
+ req[getAbortController]().abort(incoming.errored.toString());
389
389
  }
390
390
  });
391
391
  res = fetchCallback(req, { incoming, outgoing });
package/dist/vercel.js CHANGED
@@ -55,7 +55,7 @@ var Request = class extends GlobalRequest {
55
55
  if (typeof input === "object" && getRequestCache in input) {
56
56
  input = input[getRequestCache]();
57
57
  }
58
- if (options?.body instanceof ReadableStream) {
58
+ if (typeof options?.body?.getReader !== "undefined") {
59
59
  ;
60
60
  options.duplex ??= "half";
61
61
  }
@@ -238,7 +238,7 @@ var Response2 = class _Response {
238
238
  } else {
239
239
  this.#init = init;
240
240
  }
241
- if (typeof body === "string" || body instanceof ReadableStream) {
241
+ if (typeof body === "string" || typeof body?.getReader !== "undefined") {
242
242
  let headers = init?.headers || { "content-type": "text/plain; charset=UTF-8" };
243
243
  if (headers instanceof Headers) {
244
244
  headers = buildOutgoingHttpHeaders(headers);
@@ -417,8 +417,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
417
417
  try {
418
418
  req = newRequest(incoming, options.hostname);
419
419
  outgoing.on("close", () => {
420
- if (incoming.destroyed) {
421
- req[getAbortController]().abort();
420
+ if (incoming.errored) {
421
+ req[getAbortController]().abort(incoming.errored.toString());
422
422
  }
423
423
  });
424
424
  res = fetchCallback(req, { incoming, outgoing });
package/dist/vercel.mjs CHANGED
@@ -19,7 +19,7 @@ var Request = class extends GlobalRequest {
19
19
  if (typeof input === "object" && getRequestCache in input) {
20
20
  input = input[getRequestCache]();
21
21
  }
22
- if (options?.body instanceof ReadableStream) {
22
+ if (typeof options?.body?.getReader !== "undefined") {
23
23
  ;
24
24
  options.duplex ??= "half";
25
25
  }
@@ -202,7 +202,7 @@ var Response2 = class _Response {
202
202
  } else {
203
203
  this.#init = init;
204
204
  }
205
- if (typeof body === "string" || body instanceof ReadableStream) {
205
+ if (typeof body === "string" || typeof body?.getReader !== "undefined") {
206
206
  let headers = init?.headers || { "content-type": "text/plain; charset=UTF-8" };
207
207
  if (headers instanceof Headers) {
208
208
  headers = buildOutgoingHttpHeaders(headers);
@@ -381,8 +381,8 @@ var getRequestListener = (fetchCallback, options = {}) => {
381
381
  try {
382
382
  req = newRequest(incoming, options.hostname);
383
383
  outgoing.on("close", () => {
384
- if (incoming.destroyed) {
385
- req[getAbortController]().abort();
384
+ if (incoming.errored) {
385
+ req[getAbortController]().abort(incoming.errored.toString());
386
386
  }
387
387
  });
388
388
  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.0",
3
+ "version": "1.11.2",
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",