react-router-hono-server 2.26.0 → 3.0.0-next.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.
@@ -1,106 +1,92 @@
1
- import {
2
- bindIncomingRequestSocketInfo,
3
- createGetLoadContext,
4
- getBuildMode,
5
- importBuild
6
- } from "../chunk-BH64OQMW.js";
7
- import {
8
- cache
9
- } from "../chunk-YI5FED4X.js";
10
-
11
- // src/adapters/cloudflare.ts
1
+ import { a as getBuildMode, o as importBuild, r as createGetLoadContext, t as bindIncomingRequestSocketInfo } from "../helpers-DpeZU9Bf.js";
2
+ import { cache } from "../middleware.js";
12
3
  import { Hono } from "hono";
13
4
  import { createMiddleware } from "hono/factory";
14
5
  import { logger } from "hono/logger";
15
6
  import { createRequestHandler } from "react-router";
7
+ //#region src/adapters/cloudflare.ts
8
+ /**
9
+ * Create a Hono server
10
+ *
11
+ * @param config {@link HonoServerOptions} - The configuration options for the server
12
+ */
16
13
  async function createHonoServer(options) {
17
- const basename = import.meta.env.REACT_ROUTER_HONO_SERVER_BASENAME;
18
- const mergedOptions = {
19
- ...options,
20
- defaultLogger: options?.defaultLogger ?? true
21
- };
22
- const mode = getBuildMode();
23
- const PRODUCTION = mode === "production";
24
- const app = new Hono(mergedOptions.app);
25
- await mergedOptions.beforeAll?.(app);
26
- app.use(
27
- // https://developers.cloudflare.com/workers/static-assets/binding/#experimental_serve_directly
28
- `/${import.meta.env.REACT_ROUTER_HONO_SERVER_ASSETS_DIR}/*`,
29
- cache(60 * 60 * 24 * 365),
30
- // 1 year
31
- serveCloudflareAssets()
32
- );
33
- if (PRODUCTION) {
34
- app.use(
35
- // https://developers.cloudflare.com/workers/static-assets/binding/#experimental_serve_directly
36
- "*",
37
- cache(60 * 60),
38
- // 1 hour
39
- serveCloudflareAssets()
40
- );
41
- } else {
42
- const { serveStatic } = await import("@hono/node-server/serve-static");
43
- app.use(
44
- "*",
45
- cache(60 * 60),
46
- // 1 hour
47
- serveStatic({ root: "./public" })
48
- );
49
- app.use(bindIncomingRequestSocketInfo());
50
- }
51
- if (mergedOptions.defaultLogger) {
52
- app.use("*", logger());
53
- }
54
- await mergedOptions.configure?.(app);
55
- const reactRouterApp = new Hono({
56
- strict: false
57
- });
58
- reactRouterApp.use(async (c, next) => {
59
- const build = await importBuild();
60
- return createMiddleware(async (c2) => {
61
- const requestHandler = createRequestHandler(build, mode);
62
- const loadContext = mergedOptions.getLoadContext?.(c2, { build, mode });
63
- return requestHandler(c2.req.raw, loadContext instanceof Promise ? await loadContext : loadContext);
64
- })(c, next);
65
- });
66
- app.route(`${basename}`, reactRouterApp);
67
- if (basename) {
68
- app.route(`${basename}.data`, reactRouterApp);
69
- }
70
- if (!PRODUCTION) {
71
- console.log("\u{1F6A7} Running in development mode");
72
- }
73
- return app;
14
+ const basename = import.meta.env.REACT_ROUTER_HONO_SERVER_BASENAME;
15
+ const mergedOptions = {
16
+ ...options,
17
+ defaultLogger: options?.defaultLogger ?? true
18
+ };
19
+ const mode = getBuildMode();
20
+ const PRODUCTION = mode === "production";
21
+ const app = new Hono(mergedOptions.app);
22
+ /**
23
+ * Add optional middleware that runs before any built-in middleware, including assets serving.
24
+ */
25
+ await mergedOptions.beforeAll?.(app);
26
+ /**
27
+ * Serve assets files from build/client/assets
28
+ */
29
+ app.use(`/${import.meta.env.REACT_ROUTER_HONO_SERVER_ASSETS_DIR}/*`, cache(3600 * 24 * 365), serveCloudflareAssets());
30
+ /**
31
+ * Serve public files
32
+ */
33
+ if (PRODUCTION) app.use("*", cache(3600), serveCloudflareAssets());
34
+ else {
35
+ const { serveStatic } = await import("@hono/node-server/serve-static");
36
+ app.use("*", cache(3600), serveStatic({ root: "./public" }));
37
+ app.use(bindIncomingRequestSocketInfo());
38
+ }
39
+ /**
40
+ * Add logger middleware
41
+ */
42
+ if (mergedOptions.defaultLogger) app.use("*", logger());
43
+ /**
44
+ * Add optional middleware
45
+ */
46
+ await mergedOptions.configure?.(app);
47
+ /**
48
+ * Create a React Router Hono app and bind it to the root Hono server using the React Router basename
49
+ */
50
+ const reactRouterApp = new Hono({ strict: false });
51
+ reactRouterApp.use(async (c, next) => {
52
+ const build = await importBuild();
53
+ return createMiddleware(async (c) => {
54
+ const requestHandler = createRequestHandler(build, mode);
55
+ const loadContext = mergedOptions.getLoadContext?.(c, {
56
+ build,
57
+ mode
58
+ });
59
+ return requestHandler(c.req.raw, loadContext instanceof Promise ? await loadContext : loadContext);
60
+ })(c, next);
61
+ });
62
+ app.route(`${basename}`, reactRouterApp);
63
+ if (basename) app.route(`${basename}.data`, reactRouterApp);
64
+ if (!PRODUCTION) console.log("🚧 Running in development mode");
65
+ return app;
74
66
  }
75
- var warned = false;
67
+ let warned = false;
68
+ /**
69
+ * Serve static assets
70
+ *
71
+ * https://github.com/sergiodxa/remix-hono/blob/main/src/cloudflare.ts
72
+ */
76
73
  function serveCloudflareAssets() {
77
- return createMiddleware(async (c, next) => {
78
- const binding = c.env?.ASSETS;
79
- if (!binding) {
80
- if (!warned) {
81
- console.info(
82
- "\x1B[33m\nThe binding ASSETS is not set. Falling back to Cloudflare serving.\nhttps://developers.cloudflare.com/workers/static-assets/binding/#binding\n\x1B[0m"
83
- );
84
- }
85
- warned = true;
86
- return next();
87
- }
88
- try {
89
- let response = await binding.fetch(
90
- c.req.url,
91
- c.req.raw.clone()
92
- );
93
- if (response.status >= 400) {
94
- return next();
95
- }
96
- response = new Response(response.body, response);
97
- return response;
98
- } catch {
99
- return next();
100
- }
101
- });
74
+ return createMiddleware(async (c, next) => {
75
+ const binding = c.env?.ASSETS;
76
+ if (!binding) {
77
+ if (!warned) console.info("\x1B[33m\nThe binding ASSETS is not set. Falling back to Cloudflare serving.\nhttps://developers.cloudflare.com/workers/static-assets/binding/#binding\n\x1B[0m");
78
+ warned = true;
79
+ return next();
80
+ }
81
+ try {
82
+ let response = await binding.fetch(c.req.url, c.req.raw.clone());
83
+ if (response.status >= 400) return next();
84
+ response = new Response(response.body, response);
85
+ return response;
86
+ } catch {
87
+ return next();
88
+ }
89
+ });
102
90
  }
103
- export {
104
- createGetLoadContext,
105
- createHonoServer
106
- };
91
+ //#endregion
92
+ export { createGetLoadContext, createHonoServer };
@@ -1,45 +1,43 @@
1
- import { Env, Hono } from 'hono';
2
- import { ServeStaticOptions } from 'hono/serve-static';
3
- import { BlankEnv } from 'hono/types';
4
- import { H as HonoServerOptionsBase, W as WithoutWebsocket } from '../helpers-BXdVojwF.js';
5
- export { c as createGetLoadContext } from '../helpers-BXdVojwF.js';
6
- import 'hono/ws';
7
- import 'react-router';
1
+ import { i as WithoutWebsocket, n as HonoServerOptionsBase, t as createGetLoadContext } from "../helpers-CvvzWAWX.js";
2
+ import { Env, Hono } from "hono";
3
+ import { BlankEnv } from "hono/types";
4
+ import { ServeStaticOptions } from "hono/serve-static";
8
5
 
6
+ //#region src/adapters/deno.d.ts
9
7
  type CustomDenoServer = Deno.ServeTcpOptions;
10
8
  interface HonoDenoServerOptions<E extends Env = BlankEnv> extends HonoServerOptionsBase<E> {
9
+ /**
10
+ * Customize the deno server
11
+ *
12
+ * {@link https://docs.deno.com/api/deno/~/Deno.serve#parameters}
13
+ */
14
+ customDenoServer?: Partial<CustomDenoServer>;
15
+ /**
16
+ * Callback executed after server has closed and all inflight requests completed,
17
+ * before process exit. Only applicable in production mode.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * export default createHonoServer({
22
+ * onGracefulShutdown: async () => {
23
+ * await db.close();
24
+ * },
25
+ * });
26
+ * ```
27
+ */
28
+ onGracefulShutdown?: () => Promise<void> | void;
29
+ serveStaticOptions?: {
11
30
  /**
12
- * Customize the deno server
31
+ * Customize the public assets (what's in your `public` directory) serve static options.
13
32
  *
14
- * {@link https://docs.deno.com/api/deno/~/Deno.serve#parameters}
15
33
  */
16
- customDenoServer?: Partial<CustomDenoServer>;
34
+ publicAssets?: Omit<ServeStaticOptions<E>, "root">;
17
35
  /**
18
- * Callback executed after server has closed and all inflight requests completed,
19
- * before process exit. Only applicable in production mode.
36
+ * Customize the client assets (what's in your `build/client/assets` directory - React Router) serve static options.
20
37
  *
21
- * @example
22
- * ```ts
23
- * export default createHonoServer({
24
- * onGracefulShutdown: async () => {
25
- * await db.close();
26
- * },
27
- * });
28
- * ```
29
38
  */
30
- onGracefulShutdown?: () => Promise<void> | void;
31
- serveStaticOptions?: {
32
- /**
33
- * Customize the public assets (what's in your `public` directory) serve static options.
34
- *
35
- */
36
- publicAssets?: Omit<ServeStaticOptions<E>, "root">;
37
- /**
38
- * Customize the client assets (what's in your `build/client/assets` directory - React Router) serve static options.
39
- *
40
- */
41
- clientAssets?: Omit<ServeStaticOptions<E>, "root">;
42
- };
39
+ clientAssets?: Omit<ServeStaticOptions<E>, "root">;
40
+ };
43
41
  }
44
42
  type HonoServerOptionsWithoutWebSocket<E extends Env = BlankEnv> = HonoDenoServerOptions<E> & WithoutWebsocket<E>;
45
43
  type HonoServerOptions<E extends Env = BlankEnv> = HonoDenoServerOptions<E> & Omit<WithoutWebsocket<E>, "useWebSocket">;
@@ -49,5 +47,5 @@ type HonoServerOptions<E extends Env = BlankEnv> = HonoDenoServerOptions<E> & Om
49
47
  * @param config {@link HonoServerOptions} - The configuration options for the server
50
48
  */
51
49
  declare function createHonoServer<E extends Env = BlankEnv>(options?: HonoServerOptionsWithoutWebSocket<E>): Promise<Hono<E>>;
52
-
53
- export { type HonoServerOptions, createHonoServer };
50
+ //#endregion
51
+ export { HonoServerOptions, createGetLoadContext, createHonoServer };
@@ -1,110 +1,106 @@
1
- import {
2
- bindIncomingRequestSocketInfo,
3
- createGetLoadContext,
4
- getBuildMode,
5
- importBuild
6
- } from "../chunk-BH64OQMW.js";
7
- import {
8
- cache
9
- } from "../chunk-YI5FED4X.js";
10
-
11
- // src/adapters/deno.ts
1
+ import { a as getBuildMode, o as importBuild, r as createGetLoadContext, t as bindIncomingRequestSocketInfo } from "../helpers-DpeZU9Bf.js";
2
+ import { cache } from "../middleware.js";
12
3
  import { Hono } from "hono";
13
- import { serveStatic } from "hono/deno";
14
4
  import { createMiddleware } from "hono/factory";
15
5
  import { logger } from "hono/logger";
16
6
  import { createRequestHandler } from "react-router";
17
- var serverInstance;
18
- var shutdownCallback;
7
+ import { serveStatic } from "hono/deno";
8
+ //#region src/adapters/deno.ts
9
+ let serverInstance;
10
+ let shutdownCallback;
19
11
  async function createHonoServer(options) {
20
- const basename = import.meta.env.REACT_ROUTER_HONO_SERVER_BASENAME;
21
- const mergedOptions = {
22
- ...options,
23
- port: options?.port || Number(Deno.env.get("PORT")) || 3e3,
24
- defaultLogger: options?.defaultLogger ?? true
25
- };
26
- const mode = getBuildMode();
27
- const PRODUCTION = mode === "production";
28
- const clientBuildPath = `${import.meta.env.REACT_ROUTER_HONO_SERVER_BUILD_DIRECTORY}/client`;
29
- const app = new Hono(mergedOptions.app);
30
- if (PRODUCTION && mergedOptions.onGracefulShutdown) {
31
- shutdownCallback = mergedOptions.onGracefulShutdown;
32
- }
33
- if (!PRODUCTION) {
34
- app.use(bindIncomingRequestSocketInfo());
35
- }
36
- await mergedOptions.beforeAll?.(app);
37
- app.use(
38
- `/${import.meta.env.REACT_ROUTER_HONO_SERVER_ASSETS_DIR}/*`,
39
- cache(60 * 60 * 24 * 365),
40
- // 1 year
41
- serveStatic({ root: clientBuildPath, ...mergedOptions.serveStaticOptions?.clientAssets })
42
- );
43
- app.use(
44
- "*",
45
- cache(60 * 60),
46
- // 1 hour
47
- serveStatic({ root: PRODUCTION ? clientBuildPath : "./public", ...mergedOptions.serveStaticOptions?.publicAssets })
48
- );
49
- if (mergedOptions.defaultLogger) {
50
- app.use("*", logger());
51
- }
52
- await mergedOptions.configure?.(app);
53
- const reactRouterApp = new Hono({
54
- strict: false
55
- });
56
- reactRouterApp.use(async (c, next) => {
57
- const build = await importBuild();
58
- return createMiddleware(async (c2) => {
59
- const requestHandler = createRequestHandler(build, mode);
60
- const loadContext = mergedOptions.getLoadContext?.(c2, { build, mode });
61
- return requestHandler(c2.req.raw, loadContext instanceof Promise ? await loadContext : loadContext);
62
- })(c, next);
63
- });
64
- app.route(`${basename}`, reactRouterApp);
65
- if (basename) {
66
- app.route(`${basename}.data`, reactRouterApp);
67
- }
68
- const server = {
69
- ...mergedOptions.customDenoServer,
70
- port: mergedOptions.port
71
- };
72
- if (PRODUCTION) {
73
- serverInstance = Deno.serve(server, app.fetch);
74
- if (shutdownCallback != null) {
75
- let gracefulShutdownInProgress = false;
76
- const gracefulShutdown = async (signal) => {
77
- if (gracefulShutdownInProgress) return;
78
- gracefulShutdownInProgress = true;
79
- try {
80
- if (serverInstance != null) {
81
- console.log(`
82
- \u{1F4E1} Received ${signal}, shutting down gracefully...`);
83
- await serverInstance.shutdown();
84
- console.log("Server stopped, all requests completed");
85
- if (shutdownCallback) {
86
- console.log("\u{1F9F9} Running cleanup tasks...");
87
- await shutdownCallback();
88
- console.log("\u2705 Cleanup complete!");
89
- }
90
- console.log("\u{1F44B} Graceful shutdown completed");
91
- }
92
- process.exit(0);
93
- } catch (error) {
94
- console.error("\u274C Shutdown failed:", error);
95
- process.exit(1);
96
- }
97
- };
98
- if (serverInstance != null) {
99
- process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
100
- process.on("SIGINT", () => gracefulShutdown("SIGINT"));
101
- console.log("\u2705 Graceful shutdown enabled. Press Ctrl+C to shutdown gracefully.");
102
- }
103
- }
104
- }
105
- return app;
12
+ const basename = import.meta.env.REACT_ROUTER_HONO_SERVER_BASENAME;
13
+ const mergedOptions = {
14
+ ...options,
15
+ port: options?.port || Number(Deno.env.get("PORT")) || 3e3,
16
+ defaultLogger: options?.defaultLogger ?? true
17
+ };
18
+ const mode = getBuildMode();
19
+ const PRODUCTION = mode === "production";
20
+ const clientBuildPath = `${import.meta.env.REACT_ROUTER_HONO_SERVER_BUILD_DIRECTORY}/client`;
21
+ const app = new Hono(mergedOptions.app);
22
+ if (PRODUCTION && mergedOptions.onGracefulShutdown) shutdownCallback = mergedOptions.onGracefulShutdown;
23
+ if (!PRODUCTION) app.use(bindIncomingRequestSocketInfo());
24
+ /**
25
+ * Add optional middleware that runs before any built-in middleware, including assets serving.
26
+ */
27
+ await mergedOptions.beforeAll?.(app);
28
+ /**
29
+ * Serve assets files from build/client/assets
30
+ */
31
+ app.use(`/${import.meta.env.REACT_ROUTER_HONO_SERVER_ASSETS_DIR}/*`, cache(3600 * 24 * 365), serveStatic({
32
+ root: clientBuildPath,
33
+ ...mergedOptions.serveStaticOptions?.clientAssets
34
+ }));
35
+ /**
36
+ * Serve public files
37
+ */
38
+ app.use("*", cache(3600), serveStatic({
39
+ root: PRODUCTION ? clientBuildPath : "./public",
40
+ ...mergedOptions.serveStaticOptions?.publicAssets
41
+ }));
42
+ /**
43
+ * Add logger middleware
44
+ */
45
+ if (mergedOptions.defaultLogger) app.use("*", logger());
46
+ /**
47
+ * Add optional middleware
48
+ */
49
+ await mergedOptions.configure?.(app);
50
+ /**
51
+ * Create a React Router Hono app and bind it to the root Hono server using the React Router basename
52
+ */
53
+ const reactRouterApp = new Hono({ strict: false });
54
+ reactRouterApp.use(async (c, next) => {
55
+ const build = await importBuild();
56
+ return createMiddleware(async (c) => {
57
+ const requestHandler = createRequestHandler(build, mode);
58
+ const loadContext = mergedOptions.getLoadContext?.(c, {
59
+ build,
60
+ mode
61
+ });
62
+ return requestHandler(c.req.raw, loadContext instanceof Promise ? await loadContext : loadContext);
63
+ })(c, next);
64
+ });
65
+ app.route(`${basename}`, reactRouterApp);
66
+ if (basename) app.route(`${basename}.data`, reactRouterApp);
67
+ const server = {
68
+ ...mergedOptions.customDenoServer,
69
+ port: mergedOptions.port
70
+ };
71
+ if (PRODUCTION) {
72
+ serverInstance = Deno.serve(server, app.fetch);
73
+ if (shutdownCallback != null) {
74
+ let gracefulShutdownInProgress = false;
75
+ const gracefulShutdown = async (signal) => {
76
+ if (gracefulShutdownInProgress) return;
77
+ gracefulShutdownInProgress = true;
78
+ try {
79
+ if (serverInstance != null) {
80
+ console.log(`\n📡 Received ${signal}, shutting down gracefully...`);
81
+ await serverInstance.shutdown();
82
+ console.log("Server stopped, all requests completed");
83
+ if (shutdownCallback) {
84
+ console.log("🧹 Running cleanup tasks...");
85
+ await shutdownCallback();
86
+ console.log("✅ Cleanup complete!");
87
+ }
88
+ console.log("👋 Graceful shutdown completed");
89
+ }
90
+ process.exit(0);
91
+ } catch (error) {
92
+ console.error("❌ Shutdown failed:", error);
93
+ process.exit(1);
94
+ }
95
+ };
96
+ if (serverInstance != null) {
97
+ process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
98
+ process.on("SIGINT", () => gracefulShutdown("SIGINT"));
99
+ console.log("✅ Graceful shutdown enabled. Press Ctrl+C to shutdown gracefully.");
100
+ }
101
+ }
102
+ }
103
+ return app;
106
104
  }
107
- export {
108
- createGetLoadContext,
109
- createHonoServer
110
- };
105
+ //#endregion
106
+ export { createGetLoadContext, createHonoServer };
@@ -1,88 +1,83 @@
1
- import { AddressInfo } from 'node:net';
2
- import { ServerType } from '@hono/node-server';
3
- import { ServeStaticOptions } from '@hono/node-server/serve-static';
4
- import { Env, Hono } from 'hono';
5
- import { BlankEnv } from 'hono/types';
6
- import { H as HonoServerOptionsBase, a as WithWebsocket, W as WithoutWebsocket } from '../helpers-BXdVojwF.js';
7
- export { c as createGetLoadContext } from '../helpers-BXdVojwF.js';
8
- import { ServerOptions, createServer } from 'node:http';
9
- import { ServerOptions as ServerOptions$2, createServer as createServer$2, SecureServerOptions, createSecureServer } from 'node:http2';
10
- import { ServerOptions as ServerOptions$1, createServer as createServer$1 } from 'node:https';
11
- import 'hono/ws';
12
- import 'react-router';
1
+ import { i as WithoutWebsocket, n as HonoServerOptionsBase, r as WithWebsocket, t as createGetLoadContext } from "../helpers-CvvzWAWX.js";
2
+ import { ServerType } from "@hono/node-server";
3
+ import { ServeStaticOptions } from "@hono/node-server/serve-static";
4
+ import { Env, Hono } from "hono";
5
+ import { BlankEnv } from "hono/types";
6
+ import { ServerOptions, createServer } from "node:http";
7
+ import { SecureServerOptions, ServerOptions as ServerOptions$1, createSecureServer, createServer as createServer$1 } from "node:http2";
8
+ import { AddressInfo } from "node:net";
9
+ import { ServerOptions as ServerOptions$2, createServer as createServer$2 } from "node:https";
13
10
 
11
+ //#region src/types/node.https.d.ts
14
12
  type createHttpOptions = {
15
13
  serverOptions?: ServerOptions;
16
14
  createServer?: typeof createServer;
17
15
  };
18
16
  type createHttpsOptions = {
19
- serverOptions?: ServerOptions$1;
20
- createServer?: typeof createServer$1;
21
- };
22
- type createHttp2Options = {
23
17
  serverOptions?: ServerOptions$2;
24
18
  createServer?: typeof createServer$2;
25
19
  };
20
+ type createHttp2Options = {
21
+ serverOptions?: ServerOptions$1;
22
+ createServer?: typeof createServer$1;
23
+ };
26
24
  type createSecureHttp2Options = {
27
25
  serverOptions?: SecureServerOptions;
28
26
  createServer?: typeof createSecureServer;
29
27
  };
30
- type CreateNodeServerOptions =
31
- | createHttpOptions
32
- | createHttpsOptions
33
- | createHttp2Options
34
- | createSecureHttp2Options;
35
-
28
+ type CreateNodeServerOptions = createHttpOptions | createHttpsOptions | createHttp2Options | createSecureHttp2Options;
29
+ //#endregion
30
+ //#region src/adapters/node.d.ts
36
31
  interface HonoNodeServerOptions<E extends Env = BlankEnv> extends HonoServerOptionsBase<E> {
32
+ /**
33
+ * Listening listener (production mode only)
34
+ *
35
+ * It is called when the server is listening
36
+ *
37
+ * Defaults log the port
38
+ */
39
+ listeningListener?: (info: AddressInfo) => void;
40
+ /**
41
+ * Customize the node server (ex: using http2)
42
+ *
43
+ * {@link https://hono.dev/docs/getting-started/nodejs#http2}
44
+ */
45
+ customNodeServer?: CreateNodeServerOptions;
46
+ /**
47
+ * Callback executed just after `serve` from `@hono/node-server`
48
+ */
49
+ onServe?: (server: ServerType) => void;
50
+ /**
51
+ * The Node.js Adapter rewrites the global Request/Response and uses a lightweight Request/Response to improve performance.
52
+ *
53
+ * If you this behavior, set it to `true`
54
+ *
55
+ * 🚨 Setting this to `true` can break `request.clone()` if you later check `instanceof Request`.
56
+ *
57
+ * {@link https://github.com/honojs/node-server?tab=readme-ov-file#overrideglobalobjects}
58
+ *
59
+ * @default false
60
+ */
61
+ overrideGlobalObjects?: boolean;
62
+ /**
63
+ * Customize the hostname of the node server
64
+ */
65
+ hostname?: string;
66
+ /**
67
+ * Customize the serve static options
68
+ */
69
+ serveStaticOptions?: {
37
70
  /**
38
- * Listening listener (production mode only)
71
+ * Customize the public assets (what's in your `public` directory) serve static options.
39
72
  *
40
- * It is called when the server is listening
41
- *
42
- * Defaults log the port
43
73
  */
44
- listeningListener?: (info: AddressInfo) => void;
74
+ publicAssets?: Omit<ServeStaticOptions<E>, "root">;
45
75
  /**
46
- * Customize the node server (ex: using http2)
76
+ * Customize the client assets (what's in your `build/client/assets` directory - React Router) serve static options.
47
77
  *
48
- * {@link https://hono.dev/docs/getting-started/nodejs#http2}
49
- */
50
- customNodeServer?: CreateNodeServerOptions;
51
- /**
52
- * Callback executed just after `serve` from `@hono/node-server`
53
78
  */
54
- onServe?: (server: ServerType) => void;
55
- /**
56
- * The Node.js Adapter rewrites the global Request/Response and uses a lightweight Request/Response to improve performance.
57
- *
58
- * If you this behavior, set it to `true`
59
- *
60
- * 🚨 Setting this to `true` can break `request.clone()` if you later check `instanceof Request`.
61
- *
62
- * {@link https://github.com/honojs/node-server?tab=readme-ov-file#overrideglobalobjects}
63
- *
64
- * @default false
65
- */
66
- overrideGlobalObjects?: boolean;
67
- /**
68
- * Customize the hostname of the node server
69
- */
70
- hostname?: string;
71
- /**
72
- * Customize the serve static options
73
- */
74
- serveStaticOptions?: {
75
- /**
76
- * Customize the public assets (what's in your `public` directory) serve static options.
77
- *
78
- */
79
- publicAssets?: Omit<ServeStaticOptions<E>, "root">;
80
- /**
81
- * Customize the client assets (what's in your `build/client/assets` directory - React Router) serve static options.
82
- *
83
- */
84
- clientAssets?: Omit<ServeStaticOptions<E>, "root">;
85
- };
79
+ clientAssets?: Omit<ServeStaticOptions<E>, "root">;
80
+ };
86
81
  }
87
82
  type HonoServerOptionsWithWebSocket<E extends Env = BlankEnv> = HonoNodeServerOptions<E> & WithWebsocket<E>;
88
83
  type HonoServerOptionsWithoutWebSocket<E extends Env = BlankEnv> = HonoNodeServerOptions<E> & WithoutWebsocket<E>;
@@ -94,5 +89,5 @@ type HonoServerOptions<E extends Env = BlankEnv> = HonoServerOptionsWithWebSocke
94
89
  */
95
90
  declare function createHonoServer<E extends Env = BlankEnv>(options?: HonoServerOptionsWithoutWebSocket<E>): Promise<Hono<E>>;
96
91
  declare function createHonoServer<E extends Env = BlankEnv>(options?: HonoServerOptionsWithWebSocket<E>): Promise<Hono<E>>;
97
-
98
- export { type HonoServerOptions, createHonoServer };
92
+ //#endregion
93
+ export { HonoServerOptions, createGetLoadContext, createHonoServer };