hono 1.3.1 → 1.3.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/context.d.ts CHANGED
@@ -28,7 +28,7 @@ export declare class Context<RequestParamKeyType extends string = string, E = En
28
28
  get(key: string): any;
29
29
  pretty(prettyJSON: boolean, space?: number): void;
30
30
  newResponse(data: Data, init?: ResponseInit): Response;
31
- body(data: Data, status?: StatusCode, headers?: Headers): Response;
31
+ body(data: Data | null, status?: StatusCode, headers?: Headers): Response;
32
32
  text(text: string, status?: StatusCode, headers?: Headers): Response;
33
33
  json(object: object, status?: StatusCode, headers?: Headers): Response;
34
34
  html(html: string, status?: StatusCode, headers?: Headers): Response;
@@ -3,5 +3,5 @@ import type { Next } from '../../hono';
3
3
  declare type Options = {
4
4
  root: string;
5
5
  };
6
- export declare const serveStatic: (opt?: Options) => (c: Context, next: Next) => Promise<void>;
6
+ export declare const serveStatic: (opt?: Options) => (c: Context, next: Next) => Promise<Response>;
7
7
  export {};
@@ -7,7 +7,10 @@ const DEFAULT_DOCUMENT = 'index.html';
7
7
  // This middleware is available only on Cloudflare Workers.
8
8
  const serveStatic = (opt = { root: '' }) => {
9
9
  return async (c, next) => {
10
- await next();
10
+ // Do nothing if Response is already set
11
+ if (c.res) {
12
+ await next();
13
+ }
11
14
  const url = new URL(c.req.url);
12
15
  const path = (0, cloudflare_1.getKVFilePath)({
13
16
  filename: url.pathname,
@@ -20,10 +23,12 @@ const serveStatic = (opt = { root: '' }) => {
20
23
  if (mimeType) {
21
24
  c.header('Content-Type', mimeType);
22
25
  }
23
- c.res = c.body(content);
26
+ // Return Response object
27
+ return c.body(content);
24
28
  }
25
29
  else {
26
30
  console.warn(`Static file: ${path} is not found`);
31
+ await next();
27
32
  }
28
33
  };
29
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Ultrafast web framework for Cloudflare Workers.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",