generated from code-forge-io/open-source-stack
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathhono-server-options-base.d.ts
More file actions
88 lines (85 loc) · 2.48 KB
/
hono-server-options-base.d.ts
File metadata and controls
88 lines (85 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import type { Context, Env, Hono } from "hono";
import type { UpgradeWebSocket } from "hono/ws";
import type { AppLoadContext, ServerBuild } from "react-router";
export interface HonoServerOptionsBase<E extends Env> {
/**
* The base Hono app to use as a replacement for the default one created automatically
*
* It will be used to mount the React Router server on the `basename` path
* defined in the [React Router config](https://api.reactrouter.com/v7/types/_react_router_dev.config.Config.html)
*
* {@link Hono}
*/
app?: Hono<E>;
/**
* Enable the default logger
*
* Defaults to `true`
*/
defaultLogger?: boolean;
/**
* The port to start the server on
*
* Defaults to `process.env.PORT || 3000`
*/
port?: number;
/**
* Augment the React Router AppLoadContext
*
* Don't forget to declare the AppLoadContext in your app, next to where you create the Hono server
*
* ```ts
* declare module "react-router" {
* interface AppLoadContext {
* // Add your custom context here
* whatever: string;
* }
* }
* ```
*/
getLoadContext?: (
c: Context<E>,
options: {
build: ServerBuild;
mode: string;
}
) => Promise<AppLoadContext> | AppLoadContext;
/**
* Hook to add middleware that runs before any built-in middleware, including assets serving.
*
* You can use it to add protection middleware, for example.
*/
beforeAll?: (app: Hono<E>) => Promise<void> | void;
}
export interface WithWebsocket<E extends Env> {
/**
* Enable WebSockets support in `configure`
*
* For `bun` and `cloudflare` we will use the `@hono/node-ws`'s `injectWebSocket` on dev (only),
*
* Defaults to `false`
*/
useWebSocket: true;
/**
* Customize the Hono server, for example, adding middleware
*
* It is applied after the default middleware and before the React Router middleware
*/
configure: (app: Hono<E>, options: { upgradeWebSocket: UpgradeWebSocket }) => Promise<void> | void;
}
export interface WithoutWebsocket<E extends Env> {
/**
* Enable WebSockets support in `configure`
*
* For `bun` and `cloudflare` we will use the `@hono/node-ws`'s `injectWebSocket` on dev (only),
*
* Defaults to `false`
*/
useWebSocket?: false | undefined;
/**
* Customize the Hono server, for example, adding middleware
*
* It is applied after the default middleware and before the React Router middleware
*/
configure?: (app: Hono<E>) => Promise<void> | void;
}