hono 4.1.4 → 4.1.6

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.
@@ -28,11 +28,11 @@ var streamHandle = (app) => {
28
28
  statusCode: res.status,
29
29
  headers: Object.fromEntries(res.headers.entries())
30
30
  };
31
+ responseStream = awslambda.HttpResponseStream.from(responseStream, httpResponseMetadata);
31
32
  if (res.body) {
32
- await streamToNodeStream(
33
- res.body.getReader(),
34
- awslambda.HttpResponseStream.from(responseStream, httpResponseMetadata)
35
- );
33
+ await streamToNodeStream(res.body.getReader(), responseStream);
34
+ } else {
35
+ responseStream.write("");
36
36
  }
37
37
  } catch (error) {
38
38
  console.error("Error processing request:", error);
@@ -59,11 +59,11 @@ const streamHandle = (app) => {
59
59
  statusCode: res.status,
60
60
  headers: Object.fromEntries(res.headers.entries())
61
61
  };
62
+ responseStream = awslambda.HttpResponseStream.from(responseStream, httpResponseMetadata);
62
63
  if (res.body) {
63
- await streamToNodeStream(
64
- res.body.getReader(),
65
- awslambda.HttpResponseStream.from(responseStream, httpResponseMetadata)
66
- );
64
+ await streamToNodeStream(res.body.getReader(), responseStream);
65
+ } else {
66
+ responseStream.write("");
67
67
  }
68
68
  } catch (error) {
69
69
  console.error("Error processing request:", error);
@@ -52,14 +52,14 @@ class Hono extends defineDynamicClass() {
52
52
  constructor(options = {}) {
53
53
  super();
54
54
  const allMethods = [...import_router.METHODS, import_router.METHOD_NAME_ALL_LOWERCASE];
55
- allMethods.map((method) => {
55
+ allMethods.forEach((method) => {
56
56
  this[method] = (args1, ...args) => {
57
57
  if (typeof args1 === "string") {
58
58
  this.#path = args1;
59
59
  } else {
60
60
  this.addRoute(method, this.#path, args1);
61
61
  }
62
- args.map((handler) => {
62
+ args.forEach((handler) => {
63
63
  if (typeof handler !== "string") {
64
64
  this.addRoute(method, this.#path, handler);
65
65
  }
@@ -88,7 +88,7 @@ class Hono extends defineDynamicClass() {
88
88
  this.#path = "*";
89
89
  handlers.unshift(arg1);
90
90
  }
91
- handlers.map((handler) => {
91
+ handlers.forEach((handler) => {
92
92
  this.addRoute(import_router.METHOD_NAME_ALL, this.#path, handler);
93
93
  });
94
94
  return this;
@@ -22,6 +22,10 @@ __export(cache_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(cache_exports);
24
24
  const cache = (options) => {
25
+ if (!caches) {
26
+ console.log("Cache Middleware is not enabled because caches is not defined.");
27
+ return async (_c, next) => await next();
28
+ }
25
29
  if (options.wait === void 0) {
26
30
  options.wait = false;
27
31
  }
@@ -36,7 +36,7 @@ const validator = (target, validationFunc) => {
36
36
  throw new import_http_exception.HTTPException(400, { message });
37
37
  }
38
38
  if (c.req.bodyCache.json) {
39
- value = c.req.bodyCache.json;
39
+ value = await c.req.bodyCache.json;
40
40
  break;
41
41
  }
42
42
  try {
@@ -62,7 +62,7 @@ const validator = (target, validationFunc) => {
62
62
  break;
63
63
  }
64
64
  if (c.req.bodyCache.formData) {
65
- value = c.req.bodyCache.formData;
65
+ value = await c.req.bodyCache.formData;
66
66
  break;
67
67
  }
68
68
  try {
package/dist/hono-base.js CHANGED
@@ -29,14 +29,14 @@ var Hono = class extends defineDynamicClass() {
29
29
  constructor(options = {}) {
30
30
  super();
31
31
  const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE];
32
- allMethods.map((method) => {
32
+ allMethods.forEach((method) => {
33
33
  this[method] = (args1, ...args) => {
34
34
  if (typeof args1 === "string") {
35
35
  this.#path = args1;
36
36
  } else {
37
37
  this.addRoute(method, this.#path, args1);
38
38
  }
39
- args.map((handler) => {
39
+ args.forEach((handler) => {
40
40
  if (typeof handler !== "string") {
41
41
  this.addRoute(method, this.#path, handler);
42
42
  }
@@ -65,7 +65,7 @@ var Hono = class extends defineDynamicClass() {
65
65
  this.#path = "*";
66
66
  handlers.unshift(arg1);
67
67
  }
68
- handlers.map((handler) => {
68
+ handlers.forEach((handler) => {
69
69
  this.addRoute(METHOD_NAME_ALL, this.#path, handler);
70
70
  });
71
71
  return this;
@@ -1,5 +1,9 @@
1
1
  // src/middleware/cache/index.ts
2
2
  var cache = (options) => {
3
+ if (!caches) {
4
+ console.log("Cache Middleware is not enabled because caches is not defined.");
5
+ return async (_c, next) => await next();
6
+ }
3
7
  if (options.wait === void 0) {
4
8
  options.wait = false;
5
9
  }
@@ -14,7 +14,7 @@ var validator = (target, validationFunc) => {
14
14
  throw new HTTPException(400, { message });
15
15
  }
16
16
  if (c.req.bodyCache.json) {
17
- value = c.req.bodyCache.json;
17
+ value = await c.req.bodyCache.json;
18
18
  break;
19
19
  }
20
20
  try {
@@ -40,7 +40,7 @@ var validator = (target, validationFunc) => {
40
40
  break;
41
41
  }
42
42
  if (c.req.bodyCache.formData) {
43
- value = c.req.bodyCache.formData;
43
+ value = await c.req.bodyCache.formData;
44
44
  break;
45
45
  }
46
46
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.1.4",
3
+ "version": "4.1.6",
4
4
  "description": "Ultrafast web framework for the Edges",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",