@hono/node-server 2.0.0-rc.1 → 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.
@@ -68,7 +68,7 @@ const serveStatic = (options = { root: "" }) => {
68
68
  if (optionPath) filename = optionPath;
69
69
  else try {
70
70
  filename = tryDecodeURI(c.req.path);
71
- if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) throw new Error();
71
+ if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}/.test(filename)) throw new Error();
72
72
  } catch {
73
73
  await options.onNotFound?.(c.req.path, c);
74
74
  return next();
@@ -67,7 +67,7 @@ const serveStatic = (options = { root: "" }) => {
67
67
  if (optionPath) filename = optionPath;
68
68
  else try {
69
69
  filename = tryDecodeURI(c.req.path);
70
- if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) throw new Error();
70
+ if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}/.test(filename)) throw new Error();
71
71
  } catch {
72
72
  await options.onNotFound?.(c.req.path, c);
73
73
  return next();
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_constants = require('../constants-B7DBcQew.js');
2
+ const require_constants = require('../constants-BXAKTxRC.cjs');
3
3
 
4
4
  //#region src/utils/response.ts
5
5
  const RESPONSE_ALREADY_SENT = new Response(null, { headers: { [require_constants.X_ALREADY_SENT]: "true" } });
@@ -1,4 +1,4 @@
1
- import { t as X_ALREADY_SENT } from "../constants-DEKKqoym.mjs";
1
+ import { t as X_ALREADY_SENT } from "../constants-BLSFu_RU.mjs";
2
2
 
3
3
  //#region src/utils/response.ts
4
4
  const RESPONSE_ALREADY_SENT = new Response(null, { headers: { [X_ALREADY_SENT]: "true" } });
package/package.json CHANGED
@@ -1,55 +1,68 @@
1
1
  {
2
2
  "name": "@hono/node-server",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0-rc.2",
4
4
  "description": "Node.js Adapter for Hono",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "main": "dist/index.mjs",
6
+ "type": "module",
7
+ "types": "dist/index.d.mts",
7
8
  "files": [
8
9
  "dist"
9
10
  ],
10
11
  "exports": {
11
12
  ".": {
12
- "types": "./dist/index.d.ts",
13
- "require": "./dist/index.js",
14
- "import": "./dist/index.mjs"
13
+ "import": {
14
+ "types": "./dist/index.d.mts",
15
+ "default": "./dist/index.mjs"
16
+ },
17
+ "require": {
18
+ "types": "./dist/index.d.cts",
19
+ "default": "./dist/index.cjs"
20
+ }
15
21
  },
16
22
  "./serve-static": {
17
- "types": "./dist/serve-static.d.ts",
18
- "require": "./dist/serve-static.js",
19
- "import": "./dist/serve-static.mjs"
20
- },
21
- "./vercel": {
22
- "types": "./dist/vercel.d.ts",
23
- "require": "./dist/vercel.js",
24
- "import": "./dist/vercel.mjs"
23
+ "import": {
24
+ "types": "./dist/serve-static.d.mts",
25
+ "default": "./dist/serve-static.mjs"
26
+ },
27
+ "require": {
28
+ "types": "./dist/serve-static.d.cts",
29
+ "default": "./dist/serve-static.cjs"
30
+ }
25
31
  },
26
32
  "./utils/*": {
27
- "types": "./dist/utils/*.d.ts",
28
- "require": "./dist/utils/*.js",
29
- "import": "./dist/utils/*.mjs"
33
+ "import": {
34
+ "types": "./dist/utils/*.d.mts",
35
+ "default": "./dist/utils/*.mjs"
36
+ },
37
+ "require": {
38
+ "types": "./dist/utils/*.d.cts",
39
+ "default": "./dist/utils/*.cjs"
40
+ }
30
41
  },
31
42
  "./conninfo": {
32
- "types": "./dist/conninfo.d.ts",
33
- "require": "./dist/conninfo.js",
34
- "import": "./dist/conninfo.mjs"
43
+ "import": {
44
+ "types": "./dist/conninfo.d.mts",
45
+ "default": "./dist/conninfo.mjs"
46
+ },
47
+ "require": {
48
+ "types": "./dist/conninfo.d.cts",
49
+ "default": "./dist/conninfo.cjs"
50
+ }
35
51
  }
36
52
  },
37
53
  "typesVersions": {
38
54
  "*": {
39
55
  ".": [
40
- "./dist/index.d.ts"
56
+ "./dist/index.d.mts"
41
57
  ],
42
58
  "serve-static": [
43
- "./dist/serve-static.d.ts"
44
- ],
45
- "vercel": [
46
- "./dist/vercel.d.ts"
59
+ "./dist/serve-static.d.mts"
47
60
  ],
48
61
  "utils/*": [
49
- "./dist/utils/*.d.ts"
62
+ "./dist/utils/*.d.mts"
50
63
  ],
51
64
  "conninfo": [
52
- "./dist/conninfo.d.ts"
65
+ "./dist/conninfo.d.mts"
53
66
  ]
54
67
  }
55
68
  },
@@ -68,7 +81,7 @@
68
81
  "license": "MIT",
69
82
  "repository": {
70
83
  "type": "git",
71
- "url": "https://github.com/honojs/node-server.git"
84
+ "url": "git+https://github.com/honojs/node-server.git"
72
85
  },
73
86
  "homepage": "https://github.com/honojs/node-server",
74
87
  "author": "Yusuke Wada <yusuke@kamawada.com> (https://github.com/yusukebe)",
@@ -83,6 +96,7 @@
83
96
  "@hono/eslint-config": "^1.0.1",
84
97
  "@types/node": "^20.10.0",
85
98
  "@types/supertest": "^2.0.12",
99
+ "@types/ws": "^8.18.1",
86
100
  "@whatwg-node/fetch": "^0.9.14",
87
101
  "eslint": "^9.10.0",
88
102
  "hono": "^4.12.8",
@@ -92,7 +106,8 @@
92
106
  "supertest": "^6.3.3",
93
107
  "tsdown": "^0.20.3",
94
108
  "typescript": "^5.3.2",
95
- "vitest": "^4.0.18"
109
+ "vitest": "^4.0.18",
110
+ "ws": "^8.19.0"
96
111
  },
97
112
  "peerDependencies": {
98
113
  "hono": "^4"
package/dist/index.js DELETED
@@ -1,28 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_listener = require('./listener-Brd4yZ5d.js');
3
- let node_http = require("node:http");
4
-
5
- //#region src/server.ts
6
- const createAdaptorServer = (options) => {
7
- const fetchCallback = options.fetch;
8
- const requestListener = require_listener.getRequestListener(fetchCallback, {
9
- hostname: options.hostname,
10
- overrideGlobalObjects: options.overrideGlobalObjects,
11
- autoCleanupIncoming: options.autoCleanupIncoming
12
- });
13
- return (options.createServer || node_http.createServer)(options.serverOptions || {}, requestListener);
14
- };
15
- const serve = (options, listeningListener) => {
16
- const server = createAdaptorServer(options);
17
- server.listen(options?.port ?? 3e3, options.hostname, () => {
18
- const serverInfo = server.address();
19
- listeningListener && listeningListener(serverInfo);
20
- });
21
- return server;
22
- };
23
-
24
- //#endregion
25
- exports.RequestError = require_listener.RequestError;
26
- exports.createAdaptorServer = createAdaptorServer;
27
- exports.getRequestListener = require_listener.getRequestListener;
28
- exports.serve = serve;