@hono/node-server 1.19.10 → 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.
Files changed (58) hide show
  1. package/README.md +1 -7
  2. package/dist/conninfo.d.mts +4 -3
  3. package/dist/conninfo.d.ts +4 -3
  4. package/dist/conninfo.js +20 -40
  5. package/dist/conninfo.mjs +19 -16
  6. package/dist/constants-B7DBcQew.js +11 -0
  7. package/dist/constants-DEKKqoym.mjs +5 -0
  8. package/dist/index.d.mts +62 -8
  9. package/dist/index.d.ts +62 -8
  10. package/dist/index.js +28 -613
  11. package/dist/index.mjs +24 -573
  12. package/dist/listener-Brd4yZ5d.js +726 -0
  13. package/dist/listener-RIBxK9_x.mjs +715 -0
  14. package/dist/serve-static.d.mts +14 -13
  15. package/dist/serve-static.d.ts +14 -13
  16. package/dist/serve-static.js +128 -170
  17. package/dist/serve-static.mjs +127 -145
  18. package/dist/utils/response.d.mts +3 -2
  19. package/dist/utils/response.d.ts +3 -2
  20. package/dist/utils/response.js +6 -35
  21. package/dist/utils/response.mjs +6 -9
  22. package/dist/vercel.d.mts +6 -5
  23. package/dist/vercel.d.ts +6 -5
  24. package/dist/vercel.js +7 -585
  25. package/dist/vercel.mjs +6 -548
  26. package/package.json +11 -13
  27. package/dist/globals.d.mts +0 -2
  28. package/dist/globals.d.ts +0 -2
  29. package/dist/globals.js +0 -29
  30. package/dist/globals.mjs +0 -5
  31. package/dist/listener.d.mts +0 -13
  32. package/dist/listener.d.ts +0 -13
  33. package/dist/listener.js +0 -581
  34. package/dist/listener.mjs +0 -546
  35. package/dist/request.d.mts +0 -25
  36. package/dist/request.d.ts +0 -25
  37. package/dist/request.js +0 -227
  38. package/dist/request.mjs +0 -195
  39. package/dist/response.d.mts +0 -26
  40. package/dist/response.d.ts +0 -26
  41. package/dist/response.js +0 -99
  42. package/dist/response.mjs +0 -72
  43. package/dist/server.d.mts +0 -10
  44. package/dist/server.d.ts +0 -10
  45. package/dist/server.js +0 -607
  46. package/dist/server.mjs +0 -571
  47. package/dist/types.d.mts +0 -44
  48. package/dist/types.d.ts +0 -44
  49. package/dist/types.js +0 -18
  50. package/dist/types.mjs +0 -0
  51. package/dist/utils/response/constants.d.mts +0 -3
  52. package/dist/utils/response/constants.d.ts +0 -3
  53. package/dist/utils/response/constants.js +0 -30
  54. package/dist/utils/response/constants.mjs +0 -5
  55. package/dist/utils.d.mts +0 -9
  56. package/dist/utils.d.ts +0 -9
  57. package/dist/utils.js +0 -99
  58. 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 18.x. The specific required Node.js versions are as follows:
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
 
@@ -1,10 +1,11 @@
1
- import { GetConnInfo } from 'hono/conninfo';
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 };
@@ -1,10 +1,11 @@
1
- import { GetConnInfo } from 'hono/conninfo';
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
- "use strict";
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
- // src/conninfo.ts
21
- var conninfo_exports = {};
22
- __export(conninfo_exports, {
23
- getConnInfo: () => getConnInfo
24
- });
25
- module.exports = __toCommonJS(conninfo_exports);
26
- var getConnInfo = (c) => {
27
- const bindings = c.env.server ? c.env.server : c.env;
28
- const address = bindings.incoming.socket.remoteAddress;
29
- const port = bindings.incoming.socket.remotePort;
30
- const family = bindings.incoming.socket.remoteFamily;
31
- return {
32
- remote: {
33
- address,
34
- port,
35
- addressType: family === "IPv4" ? "IPv4" : family === "IPv6" ? "IPv6" : void 0
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
- // Annotate the CommonJS export names for ESM import in node:
40
- 0 && (module.exports = {
41
- getConnInfo
42
- });
20
+
21
+ //#endregion
22
+ exports.getConnInfo = getConnInfo;
package/dist/conninfo.mjs CHANGED
@@ -1,17 +1,20 @@
1
- // src/conninfo.ts
2
- var getConnInfo = (c) => {
3
- const bindings = c.env.server ? c.env.server : c.env;
4
- const address = bindings.incoming.socket.remoteAddress;
5
- const port = bindings.incoming.socket.remotePort;
6
- const family = bindings.incoming.socket.remoteFamily;
7
- return {
8
- remote: {
9
- address,
10
- port,
11
- addressType: family === "IPv4" ? "IPv4" : family === "IPv6" ? "IPv6" : void 0
12
- }
13
- };
14
- };
15
- export {
16
- getConnInfo
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 };
@@ -0,0 +1,11 @@
1
+
2
+ //#region src/utils/response/constants.ts
3
+ const X_ALREADY_SENT = "x-hono-already-sent";
4
+
5
+ //#endregion
6
+ Object.defineProperty(exports, 'X_ALREADY_SENT', {
7
+ enumerable: true,
8
+ get: function () {
9
+ return X_ALREADY_SENT;
10
+ }
11
+ });
@@ -0,0 +1,5 @@
1
+ //#region src/utils/response/constants.ts
2
+ const X_ALREADY_SENT = "x-hono-already-sent";
3
+
4
+ //#endregion
5
+ export { X_ALREADY_SENT as t };
package/dist/index.d.mts CHANGED
@@ -1,8 +1,62 @@
1
- export { createAdaptorServer, serve } from './server.mjs';
2
- export { getRequestListener } from './listener.mjs';
3
- export { RequestError } from './request.mjs';
4
- export { Http2Bindings, HttpBindings, ServerType } from './types.mjs';
5
- import 'node:net';
6
- import 'node:http';
7
- import 'node:http2';
8
- import 'node:https';
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
- export { createAdaptorServer, serve } from './server.js';
2
- export { getRequestListener } from './listener.js';
3
- export { RequestError } from './request.js';
4
- export { Http2Bindings, HttpBindings, ServerType } from './types.js';
5
- import 'node:net';
6
- import 'node:http';
7
- import 'node:http2';
8
- import 'node:https';
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 };