@hono/node-server 1.19.11 → 2.0.0-rc.1
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 +1 -7
- package/dist/conninfo.d.mts +4 -3
- package/dist/conninfo.d.ts +4 -3
- package/dist/conninfo.js +20 -40
- package/dist/conninfo.mjs +19 -16
- package/dist/constants-B7DBcQew.js +11 -0
- package/dist/constants-DEKKqoym.mjs +5 -0
- package/dist/index.d.mts +62 -8
- package/dist/index.d.ts +62 -8
- package/dist/index.js +28 -632
- package/dist/index.mjs +24 -592
- package/dist/listener-Brd4yZ5d.js +726 -0
- package/dist/listener-RIBxK9_x.mjs +715 -0
- package/dist/serve-static.d.mts +14 -13
- package/dist/serve-static.d.ts +14 -13
- package/dist/serve-static.js +128 -170
- package/dist/serve-static.mjs +127 -145
- package/dist/utils/response.d.mts +3 -2
- package/dist/utils/response.d.ts +3 -2
- package/dist/utils/response.js +6 -35
- package/dist/utils/response.mjs +6 -9
- package/dist/vercel.d.mts +6 -5
- package/dist/vercel.d.ts +6 -5
- package/dist/vercel.js +7 -604
- package/dist/vercel.mjs +6 -567
- package/package.json +11 -13
- 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/listener.d.mts +0 -13
- package/dist/listener.d.ts +0 -13
- package/dist/listener.js +0 -600
- package/dist/listener.mjs +0 -565
- package/dist/request.d.mts +0 -25
- package/dist/request.d.ts +0 -25
- package/dist/request.js +0 -227
- package/dist/request.mjs +0 -195
- package/dist/response.d.mts +0 -26
- package/dist/response.d.ts +0 -26
- package/dist/response.js +0 -101
- package/dist/response.mjs +0 -74
- package/dist/server.d.mts +0 -10
- package/dist/server.d.ts +0 -10
- package/dist/server.js +0 -626
- package/dist/server.mjs +0 -590
- 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.d.mts +0 -9
- package/dist/utils.d.ts +0 -9
- package/dist/utils.js +0 -99
- package/dist/utils.mjs +0 -71
package/README.md
CHANGED
|
@@ -38,13 +38,7 @@ Statistics Avg Stdev Max
|
|
|
38
38
|
|
|
39
39
|
## Requirements
|
|
40
40
|
|
|
41
|
-
It works on Node.js versions greater than
|
|
42
|
-
|
|
43
|
-
- 18.x => 18.14.1+
|
|
44
|
-
- 19.x => 19.7.0+
|
|
45
|
-
- 20.x => 20.0.0+
|
|
46
|
-
|
|
47
|
-
Essentially, you can simply use the latest version of each major release.
|
|
41
|
+
It works on Node.js versions greater than 20.x.
|
|
48
42
|
|
|
49
43
|
## Installation
|
|
50
44
|
|
package/dist/conninfo.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { GetConnInfo } from
|
|
1
|
+
import { GetConnInfo } from "hono/conninfo";
|
|
2
2
|
|
|
3
|
+
//#region src/conninfo.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* ConnInfo Helper for Node.js
|
|
5
6
|
* @param c Context
|
|
6
7
|
* @returns ConnInfo
|
|
7
8
|
*/
|
|
8
9
|
declare const getConnInfo: GetConnInfo;
|
|
9
|
-
|
|
10
|
-
export { getConnInfo };
|
|
10
|
+
//#endregion
|
|
11
|
+
export { getConnInfo };
|
package/dist/conninfo.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { GetConnInfo } from
|
|
1
|
+
import { GetConnInfo } from "hono/conninfo";
|
|
2
2
|
|
|
3
|
+
//#region src/conninfo.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* ConnInfo Helper for Node.js
|
|
5
6
|
* @param c Context
|
|
6
7
|
* @returns ConnInfo
|
|
7
8
|
*/
|
|
8
9
|
declare const getConnInfo: GetConnInfo;
|
|
9
|
-
|
|
10
|
-
export { getConnInfo };
|
|
10
|
+
//#endregion
|
|
11
|
+
export { getConnInfo };
|
package/dist/conninfo.js
CHANGED
|
@@ -1,42 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
};
|
|
3
|
+
//#region src/conninfo.ts
|
|
4
|
+
/**
|
|
5
|
+
* ConnInfo Helper for Node.js
|
|
6
|
+
* @param c Context
|
|
7
|
+
* @returns ConnInfo
|
|
8
|
+
*/
|
|
9
|
+
const getConnInfo = (c) => {
|
|
10
|
+
const bindings = c.env.server ? c.env.server : c.env;
|
|
11
|
+
const address = bindings.incoming.socket.remoteAddress;
|
|
12
|
+
const port = bindings.incoming.socket.remotePort;
|
|
13
|
+
const family = bindings.incoming.socket.remoteFamily;
|
|
14
|
+
return { remote: {
|
|
15
|
+
address,
|
|
16
|
+
port,
|
|
17
|
+
addressType: family === "IPv4" ? "IPv4" : family === "IPv6" ? "IPv6" : void 0
|
|
18
|
+
} };
|
|
38
19
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.getConnInfo = getConnInfo;
|
package/dist/conninfo.mjs
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
//#region src/conninfo.ts
|
|
2
|
+
/**
|
|
3
|
+
* ConnInfo Helper for Node.js
|
|
4
|
+
* @param c Context
|
|
5
|
+
* @returns ConnInfo
|
|
6
|
+
*/
|
|
7
|
+
const getConnInfo = (c) => {
|
|
8
|
+
const bindings = c.env.server ? c.env.server : c.env;
|
|
9
|
+
const address = bindings.incoming.socket.remoteAddress;
|
|
10
|
+
const port = bindings.incoming.socket.remotePort;
|
|
11
|
+
const family = bindings.incoming.socket.remoteFamily;
|
|
12
|
+
return { remote: {
|
|
13
|
+
address,
|
|
14
|
+
port,
|
|
15
|
+
addressType: family === "IPv4" ? "IPv4" : family === "IPv6" ? "IPv6" : void 0
|
|
16
|
+
} };
|
|
17
17
|
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getConnInfo };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 { AddressInfo } from "node:net";
|
|
4
|
+
import { ServerOptions as ServerOptions$2, createServer as createServer$2 } from "node:https";
|
|
5
|
+
|
|
6
|
+
//#region src/types.d.ts
|
|
7
|
+
type HttpBindings = {
|
|
8
|
+
incoming: IncomingMessage;
|
|
9
|
+
outgoing: ServerResponse;
|
|
10
|
+
};
|
|
11
|
+
type Http2Bindings = {
|
|
12
|
+
incoming: Http2ServerRequest;
|
|
13
|
+
outgoing: Http2ServerResponse;
|
|
14
|
+
};
|
|
15
|
+
type FetchCallback = (request: Request, env: HttpBindings | Http2Bindings) => Promise<unknown> | unknown;
|
|
16
|
+
type ServerType = Server | Http2Server | Http2SecureServer;
|
|
17
|
+
type createHttpOptions = {
|
|
18
|
+
serverOptions?: ServerOptions;
|
|
19
|
+
createServer?: typeof createServer;
|
|
20
|
+
};
|
|
21
|
+
type createHttpsOptions = {
|
|
22
|
+
serverOptions?: ServerOptions$2;
|
|
23
|
+
createServer?: typeof createServer$2;
|
|
24
|
+
};
|
|
25
|
+
type createHttp2Options = {
|
|
26
|
+
serverOptions?: ServerOptions$1;
|
|
27
|
+
createServer?: typeof createServer$1;
|
|
28
|
+
};
|
|
29
|
+
type createSecureHttp2Options = {
|
|
30
|
+
serverOptions?: SecureServerOptions;
|
|
31
|
+
createServer?: typeof createSecureServer;
|
|
32
|
+
};
|
|
33
|
+
type ServerOptions$3 = createHttpOptions | createHttpsOptions | createHttp2Options | createSecureHttp2Options;
|
|
34
|
+
type Options = {
|
|
35
|
+
fetch: FetchCallback;
|
|
36
|
+
overrideGlobalObjects?: boolean;
|
|
37
|
+
autoCleanupIncoming?: boolean;
|
|
38
|
+
port?: number;
|
|
39
|
+
hostname?: string;
|
|
40
|
+
} & ServerOptions$3;
|
|
41
|
+
type CustomErrorHandler = (err: unknown) => void | Response | Promise<void | Response>;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/server.d.ts
|
|
44
|
+
declare const createAdaptorServer: (options: Options) => ServerType;
|
|
45
|
+
declare const serve: (options: Options, listeningListener?: (info: AddressInfo) => void) => ServerType;
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/listener.d.ts
|
|
48
|
+
declare const getRequestListener: (fetchCallback: FetchCallback, options?: {
|
|
49
|
+
hostname?: string;
|
|
50
|
+
errorHandler?: CustomErrorHandler;
|
|
51
|
+
overrideGlobalObjects?: boolean;
|
|
52
|
+
autoCleanupIncoming?: boolean;
|
|
53
|
+
}) => (incoming: IncomingMessage | Http2ServerRequest, outgoing: ServerResponse | Http2ServerResponse) => Promise<void>;
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/error.d.ts
|
|
56
|
+
declare class RequestError extends Error {
|
|
57
|
+
constructor(message: string, options?: {
|
|
58
|
+
cause?: unknown;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { type Http2Bindings, type HttpBindings, RequestError, type ServerType, createAdaptorServer, getRequestListener, serve };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { AddressInfo } from "node:net";
|
|
2
|
+
import { IncomingMessage, Server, ServerOptions, ServerResponse, createServer } from "node:http";
|
|
3
|
+
import { Http2SecureServer, Http2Server, Http2ServerRequest, Http2ServerResponse, SecureServerOptions, ServerOptions as ServerOptions$1, createSecureServer, createServer as createServer$1 } from "node:http2";
|
|
4
|
+
import { ServerOptions as ServerOptions$2, createServer as createServer$2 } from "node:https";
|
|
5
|
+
|
|
6
|
+
//#region src/types.d.ts
|
|
7
|
+
type HttpBindings = {
|
|
8
|
+
incoming: IncomingMessage;
|
|
9
|
+
outgoing: ServerResponse;
|
|
10
|
+
};
|
|
11
|
+
type Http2Bindings = {
|
|
12
|
+
incoming: Http2ServerRequest;
|
|
13
|
+
outgoing: Http2ServerResponse;
|
|
14
|
+
};
|
|
15
|
+
type FetchCallback = (request: Request, env: HttpBindings | Http2Bindings) => Promise<unknown> | unknown;
|
|
16
|
+
type ServerType = Server | Http2Server | Http2SecureServer;
|
|
17
|
+
type createHttpOptions = {
|
|
18
|
+
serverOptions?: ServerOptions;
|
|
19
|
+
createServer?: typeof createServer;
|
|
20
|
+
};
|
|
21
|
+
type createHttpsOptions = {
|
|
22
|
+
serverOptions?: ServerOptions$2;
|
|
23
|
+
createServer?: typeof createServer$2;
|
|
24
|
+
};
|
|
25
|
+
type createHttp2Options = {
|
|
26
|
+
serverOptions?: ServerOptions$1;
|
|
27
|
+
createServer?: typeof createServer$1;
|
|
28
|
+
};
|
|
29
|
+
type createSecureHttp2Options = {
|
|
30
|
+
serverOptions?: SecureServerOptions;
|
|
31
|
+
createServer?: typeof createSecureServer;
|
|
32
|
+
};
|
|
33
|
+
type ServerOptions$3 = createHttpOptions | createHttpsOptions | createHttp2Options | createSecureHttp2Options;
|
|
34
|
+
type Options = {
|
|
35
|
+
fetch: FetchCallback;
|
|
36
|
+
overrideGlobalObjects?: boolean;
|
|
37
|
+
autoCleanupIncoming?: boolean;
|
|
38
|
+
port?: number;
|
|
39
|
+
hostname?: string;
|
|
40
|
+
} & ServerOptions$3;
|
|
41
|
+
type CustomErrorHandler = (err: unknown) => void | Response | Promise<void | Response>;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/server.d.ts
|
|
44
|
+
declare const createAdaptorServer: (options: Options) => ServerType;
|
|
45
|
+
declare const serve: (options: Options, listeningListener?: (info: AddressInfo) => void) => ServerType;
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/listener.d.ts
|
|
48
|
+
declare const getRequestListener: (fetchCallback: FetchCallback, options?: {
|
|
49
|
+
hostname?: string;
|
|
50
|
+
errorHandler?: CustomErrorHandler;
|
|
51
|
+
overrideGlobalObjects?: boolean;
|
|
52
|
+
autoCleanupIncoming?: boolean;
|
|
53
|
+
}) => (incoming: IncomingMessage | Http2ServerRequest, outgoing: ServerResponse | Http2ServerResponse) => Promise<void>;
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/error.d.ts
|
|
56
|
+
declare class RequestError extends Error {
|
|
57
|
+
constructor(message: string, options?: {
|
|
58
|
+
cause?: unknown;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { type Http2Bindings, type HttpBindings, RequestError, type ServerType, createAdaptorServer, getRequestListener, serve };
|