@hono/node-server 1.19.14 → 2.0.0-rc.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/README.md +56 -18
- package/dist/conninfo.cjs +22 -0
- package/dist/{conninfo.d.ts → conninfo.d.cts} +4 -3
- package/dist/conninfo.d.mts +4 -3
- package/dist/conninfo.mjs +19 -16
- package/dist/constants-BLSFu_RU.mjs +5 -0
- package/dist/constants-BXAKTxRC.cjs +11 -0
- package/dist/index.cjs +1006 -0
- package/dist/index.d.cts +73 -0
- package/dist/index.d.mts +73 -8
- package/dist/index.mjs +976 -637
- package/dist/serve-static.cjs +135 -0
- package/dist/serve-static.d.cts +18 -0
- package/dist/serve-static.d.mts +14 -13
- package/dist/serve-static.mjs +127 -145
- package/dist/utils/response.cjs +8 -0
- package/dist/utils/response.d.cts +4 -0
- package/dist/utils/response.d.mts +3 -2
- package/dist/utils/response.mjs +6 -9
- package/package.json +53 -40
- package/dist/conninfo.js +0 -42
- package/dist/globals.d.mts +0 -2
- package/dist/globals.d.ts +0 -2
- package/dist/globals.js +0 -29
- package/dist/globals.mjs +0 -5
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -702
- package/dist/listener.d.mts +0 -13
- package/dist/listener.d.ts +0 -13
- package/dist/listener.js +0 -670
- package/dist/listener.mjs +0 -635
- package/dist/request.d.mts +0 -25
- package/dist/request.d.ts +0 -25
- package/dist/request.js +0 -238
- package/dist/request.mjs +0 -206
- package/dist/response.d.mts +0 -26
- package/dist/response.d.ts +0 -26
- package/dist/response.js +0 -112
- package/dist/response.mjs +0 -85
- package/dist/serve-static.d.ts +0 -17
- package/dist/serve-static.js +0 -177
- package/dist/server.d.mts +0 -10
- package/dist/server.d.ts +0 -10
- package/dist/server.js +0 -696
- package/dist/server.mjs +0 -660
- package/dist/types.d.mts +0 -44
- package/dist/types.d.ts +0 -44
- package/dist/types.js +0 -18
- package/dist/types.mjs +0 -0
- package/dist/utils/response/constants.d.mts +0 -3
- package/dist/utils/response/constants.d.ts +0 -3
- package/dist/utils/response/constants.js +0 -30
- package/dist/utils/response/constants.mjs +0 -5
- package/dist/utils/response.d.ts +0 -3
- package/dist/utils/response.js +0 -37
- package/dist/utils.d.mts +0 -9
- package/dist/utils.d.ts +0 -9
- package/dist/utils.js +0 -99
- package/dist/utils.mjs +0 -71
- package/dist/vercel.d.mts +0 -7
- package/dist/vercel.d.ts +0 -7
- package/dist/vercel.js +0 -677
- package/dist/vercel.mjs +0 -640
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { AddressInfo } from "node:net";
|
|
2
|
+
import { WebSocket, WebSocketServer } from "ws";
|
|
3
|
+
import { IncomingMessage, Server, ServerOptions, ServerResponse, createServer } from "node:http";
|
|
4
|
+
import { Http2SecureServer, Http2Server, Http2ServerRequest, Http2ServerResponse, SecureServerOptions, ServerOptions as ServerOptions$1, createSecureServer, createServer as createServer$1 } from "node:http2";
|
|
5
|
+
import { ServerOptions as ServerOptions$2, createServer as createServer$2 } from "node:https";
|
|
6
|
+
import { UpgradeWebSocket } from "hono/ws";
|
|
7
|
+
|
|
8
|
+
//#region src/types.d.ts
|
|
9
|
+
type HttpBindings = {
|
|
10
|
+
incoming: IncomingMessage;
|
|
11
|
+
outgoing: ServerResponse;
|
|
12
|
+
};
|
|
13
|
+
type Http2Bindings = {
|
|
14
|
+
incoming: Http2ServerRequest;
|
|
15
|
+
outgoing: Http2ServerResponse;
|
|
16
|
+
};
|
|
17
|
+
type FetchCallback = (request: Request, env: HttpBindings | Http2Bindings) => Promise<unknown> | unknown;
|
|
18
|
+
type ServerType = Server | Http2Server | Http2SecureServer;
|
|
19
|
+
type createHttpOptions = {
|
|
20
|
+
serverOptions?: ServerOptions;
|
|
21
|
+
createServer?: typeof createServer;
|
|
22
|
+
};
|
|
23
|
+
type createHttpsOptions = {
|
|
24
|
+
serverOptions?: ServerOptions$2;
|
|
25
|
+
createServer?: typeof createServer$2;
|
|
26
|
+
};
|
|
27
|
+
type createHttp2Options = {
|
|
28
|
+
serverOptions?: ServerOptions$1;
|
|
29
|
+
createServer?: typeof createServer$1;
|
|
30
|
+
};
|
|
31
|
+
type createSecureHttp2Options = {
|
|
32
|
+
serverOptions?: SecureServerOptions;
|
|
33
|
+
createServer?: typeof createSecureServer;
|
|
34
|
+
};
|
|
35
|
+
type ServerOptions$3 = createHttpOptions | createHttpsOptions | createHttp2Options | createSecureHttp2Options;
|
|
36
|
+
type Options = {
|
|
37
|
+
fetch: FetchCallback;
|
|
38
|
+
overrideGlobalObjects?: boolean;
|
|
39
|
+
autoCleanupIncoming?: boolean;
|
|
40
|
+
port?: number;
|
|
41
|
+
hostname?: string;
|
|
42
|
+
websocket?: {
|
|
43
|
+
server: WebSocketServer;
|
|
44
|
+
};
|
|
45
|
+
} & ServerOptions$3;
|
|
46
|
+
type CustomErrorHandler = (err: unknown) => void | Response | Promise<void | Response>;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/server.d.ts
|
|
49
|
+
declare const createAdaptorServer: (options: Options) => ServerType;
|
|
50
|
+
declare const serve: (options: Options, listeningListener?: (info: AddressInfo) => void) => ServerType;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/websocket.d.ts
|
|
53
|
+
type UpgradeWebSocketOptions = {
|
|
54
|
+
onError: (err: unknown) => void;
|
|
55
|
+
};
|
|
56
|
+
declare const upgradeWebSocket: UpgradeWebSocket<WebSocket, UpgradeWebSocketOptions>;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/listener.d.ts
|
|
59
|
+
declare const getRequestListener: (fetchCallback: FetchCallback, options?: {
|
|
60
|
+
hostname?: string;
|
|
61
|
+
errorHandler?: CustomErrorHandler;
|
|
62
|
+
overrideGlobalObjects?: boolean;
|
|
63
|
+
autoCleanupIncoming?: boolean;
|
|
64
|
+
}) => (incoming: IncomingMessage | Http2ServerRequest, outgoing: ServerResponse | Http2ServerResponse) => Promise<void>;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/error.d.ts
|
|
67
|
+
declare class RequestError extends Error {
|
|
68
|
+
constructor(message: string, options?: {
|
|
69
|
+
cause?: unknown;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { type Http2Bindings, type HttpBindings, RequestError, type ServerType, createAdaptorServer, getRequestListener, serve, upgradeWebSocket };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { IncomingMessage, Server, ServerOptions, ServerResponse, createServer } from "node:http";
|
|
2
|
+
import { Http2SecureServer, Http2Server, Http2ServerRequest, Http2ServerResponse, SecureServerOptions, ServerOptions as ServerOptions$1, createSecureServer, createServer as createServer$1 } from "node:http2";
|
|
3
|
+
import { UpgradeWebSocket } from "hono/ws";
|
|
4
|
+
import { AddressInfo } from "node:net";
|
|
5
|
+
import { WebSocket, WebSocketServer } from "ws";
|
|
6
|
+
import { ServerOptions as ServerOptions$2, createServer as createServer$2 } from "node:https";
|
|
7
|
+
|
|
8
|
+
//#region src/types.d.ts
|
|
9
|
+
type HttpBindings = {
|
|
10
|
+
incoming: IncomingMessage;
|
|
11
|
+
outgoing: ServerResponse;
|
|
12
|
+
};
|
|
13
|
+
type Http2Bindings = {
|
|
14
|
+
incoming: Http2ServerRequest;
|
|
15
|
+
outgoing: Http2ServerResponse;
|
|
16
|
+
};
|
|
17
|
+
type FetchCallback = (request: Request, env: HttpBindings | Http2Bindings) => Promise<unknown> | unknown;
|
|
18
|
+
type ServerType = Server | Http2Server | Http2SecureServer;
|
|
19
|
+
type createHttpOptions = {
|
|
20
|
+
serverOptions?: ServerOptions;
|
|
21
|
+
createServer?: typeof createServer;
|
|
22
|
+
};
|
|
23
|
+
type createHttpsOptions = {
|
|
24
|
+
serverOptions?: ServerOptions$2;
|
|
25
|
+
createServer?: typeof createServer$2;
|
|
26
|
+
};
|
|
27
|
+
type createHttp2Options = {
|
|
28
|
+
serverOptions?: ServerOptions$1;
|
|
29
|
+
createServer?: typeof createServer$1;
|
|
30
|
+
};
|
|
31
|
+
type createSecureHttp2Options = {
|
|
32
|
+
serverOptions?: SecureServerOptions;
|
|
33
|
+
createServer?: typeof createSecureServer;
|
|
34
|
+
};
|
|
35
|
+
type ServerOptions$3 = createHttpOptions | createHttpsOptions | createHttp2Options | createSecureHttp2Options;
|
|
36
|
+
type Options = {
|
|
37
|
+
fetch: FetchCallback;
|
|
38
|
+
overrideGlobalObjects?: boolean;
|
|
39
|
+
autoCleanupIncoming?: boolean;
|
|
40
|
+
port?: number;
|
|
41
|
+
hostname?: string;
|
|
42
|
+
websocket?: {
|
|
43
|
+
server: WebSocketServer;
|
|
44
|
+
};
|
|
45
|
+
} & ServerOptions$3;
|
|
46
|
+
type CustomErrorHandler = (err: unknown) => void | Response | Promise<void | Response>;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/server.d.ts
|
|
49
|
+
declare const createAdaptorServer: (options: Options) => ServerType;
|
|
50
|
+
declare const serve: (options: Options, listeningListener?: (info: AddressInfo) => void) => ServerType;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/websocket.d.ts
|
|
53
|
+
type UpgradeWebSocketOptions = {
|
|
54
|
+
onError: (err: unknown) => void;
|
|
55
|
+
};
|
|
56
|
+
declare const upgradeWebSocket: UpgradeWebSocket<WebSocket, UpgradeWebSocketOptions>;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/listener.d.ts
|
|
59
|
+
declare const getRequestListener: (fetchCallback: FetchCallback, options?: {
|
|
60
|
+
hostname?: string;
|
|
61
|
+
errorHandler?: CustomErrorHandler;
|
|
62
|
+
overrideGlobalObjects?: boolean;
|
|
63
|
+
autoCleanupIncoming?: boolean;
|
|
64
|
+
}) => (incoming: IncomingMessage | Http2ServerRequest, outgoing: ServerResponse | Http2ServerResponse) => Promise<void>;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/error.d.ts
|
|
67
|
+
declare class RequestError extends Error {
|
|
68
|
+
constructor(message: string, options?: {
|
|
69
|
+
cause?: unknown;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { type Http2Bindings, type HttpBindings, RequestError, type ServerType, createAdaptorServer, getRequestListener, serve, upgradeWebSocket };
|