@hono/node-server 1.2.3 → 1.3.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/dist/globals.js +78 -0
- package/dist/globals.mjs +78 -0
- package/dist/index.js +221 -73
- package/dist/index.mjs +221 -73
- package/dist/listener.d.mts +1 -1
- package/dist/listener.d.ts +1 -1
- package/dist/listener.js +221 -71
- package/dist/listener.mjs +221 -73
- package/dist/request.d.mts +6 -0
- package/dist/request.d.ts +6 -0
- package/dist/request.js +93 -0
- package/dist/request.mjs +68 -0
- package/dist/response.d.mts +15 -0
- package/dist/response.d.ts +15 -0
- package/dist/response.js +106 -0
- package/dist/response.mjs +77 -0
- package/dist/serve-static.d.mts +1 -1
- package/dist/serve-static.d.ts +1 -1
- package/dist/server.js +221 -73
- package/dist/server.mjs +221 -73
- package/dist/types.d.mts +9 -9
- package/dist/types.d.ts +9 -9
- package/dist/utils.d.mts +3 -1
- package/dist/utils.d.ts +3 -1
- package/dist/utils.js +18 -0
- package/dist/utils.mjs +17 -0
- package/dist/vercel.d.mts +1 -1
- package/dist/vercel.d.ts +1 -1
- package/dist/vercel.js +221 -73
- package/dist/vercel.mjs +221 -73
- package/package.json +3 -4
package/dist/server.mjs
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
1
|
// src/server.ts
|
|
2
2
|
import { createServer as createServerHTTP } from "http";
|
|
3
3
|
|
|
4
|
-
// src/listener.ts
|
|
5
|
-
import { Readable } from "stream";
|
|
6
|
-
|
|
7
4
|
// src/globals.ts
|
|
8
5
|
import crypto from "crypto";
|
|
9
|
-
var webFetch = global.fetch;
|
|
10
|
-
if (typeof global.crypto === "undefined") {
|
|
11
|
-
global.crypto = crypto;
|
|
12
|
-
}
|
|
13
|
-
global.fetch = (info, init) => {
|
|
14
|
-
init = {
|
|
15
|
-
// Disable compression handling so people can return the result of a fetch
|
|
16
|
-
// directly in the loader without messing with the Content-Encoding header.
|
|
17
|
-
compress: false,
|
|
18
|
-
...init
|
|
19
|
-
};
|
|
20
|
-
return webFetch(info, init);
|
|
21
|
-
};
|
|
22
6
|
|
|
23
7
|
// src/utils.ts
|
|
24
8
|
function writeFromReadableStream(stream, writable) {
|
|
@@ -59,75 +43,239 @@ function writeFromReadableStream(stream, writable) {
|
|
|
59
43
|
}
|
|
60
44
|
}
|
|
61
45
|
}
|
|
46
|
+
var buildOutgoingHttpHeaders = (headers) => {
|
|
47
|
+
const res = {};
|
|
48
|
+
const cookies = [];
|
|
49
|
+
for (const [k, v] of headers) {
|
|
50
|
+
if (k === "set-cookie") {
|
|
51
|
+
cookies.push(v);
|
|
52
|
+
} else {
|
|
53
|
+
res[k] = v;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (cookies.length > 0) {
|
|
57
|
+
res["set-cookie"] = cookies;
|
|
58
|
+
}
|
|
59
|
+
res["content-type"] ??= "text/plain;charset=UTF-8";
|
|
60
|
+
return res;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/response.ts
|
|
64
|
+
var responseCache = Symbol("responseCache");
|
|
65
|
+
var cacheKey = Symbol("cache");
|
|
66
|
+
var globalResponse = global.Response;
|
|
67
|
+
var Response2 = class {
|
|
68
|
+
#body;
|
|
69
|
+
#init;
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
get cache() {
|
|
72
|
+
delete this[cacheKey];
|
|
73
|
+
return this[responseCache] ||= new globalResponse(this.#body, this.#init);
|
|
74
|
+
}
|
|
75
|
+
constructor(body, init) {
|
|
76
|
+
this.#body = body;
|
|
77
|
+
this.#init = init;
|
|
78
|
+
if (typeof body === "string" || body instanceof ReadableStream) {
|
|
79
|
+
let headers = init?.headers || { "content-type": "text/plain;charset=UTF-8" };
|
|
80
|
+
if (headers instanceof Headers) {
|
|
81
|
+
headers = buildOutgoingHttpHeaders(headers);
|
|
82
|
+
}
|
|
83
|
+
this[cacheKey] = [init?.status || 200, body, headers];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
[
|
|
88
|
+
"body",
|
|
89
|
+
"bodyUsed",
|
|
90
|
+
"headers",
|
|
91
|
+
"ok",
|
|
92
|
+
"redirected",
|
|
93
|
+
"status",
|
|
94
|
+
"statusText",
|
|
95
|
+
"trailers",
|
|
96
|
+
"type",
|
|
97
|
+
"url"
|
|
98
|
+
].forEach((k) => {
|
|
99
|
+
Object.defineProperty(Response2.prototype, k, {
|
|
100
|
+
get() {
|
|
101
|
+
return this.cache[k];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
|
|
106
|
+
Object.defineProperty(Response2.prototype, k, {
|
|
107
|
+
value: function() {
|
|
108
|
+
return this.cache[k]();
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
Object.setPrototypeOf(Response2, globalResponse);
|
|
113
|
+
Object.setPrototypeOf(Response2.prototype, globalResponse.prototype);
|
|
114
|
+
Object.defineProperty(global, "Response", {
|
|
115
|
+
value: Response2
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// src/globals.ts
|
|
119
|
+
Object.defineProperty(global, "Response", {
|
|
120
|
+
value: Response2
|
|
121
|
+
});
|
|
122
|
+
var webFetch = global.fetch;
|
|
123
|
+
if (typeof global.crypto === "undefined") {
|
|
124
|
+
global.crypto = crypto;
|
|
125
|
+
}
|
|
126
|
+
global.fetch = (info, init) => {
|
|
127
|
+
init = {
|
|
128
|
+
// Disable compression handling so people can return the result of a fetch
|
|
129
|
+
// directly in the loader without messing with the Content-Encoding header.
|
|
130
|
+
compress: false,
|
|
131
|
+
...init
|
|
132
|
+
};
|
|
133
|
+
return webFetch(info, init);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// src/request.ts
|
|
137
|
+
import { Readable } from "stream";
|
|
138
|
+
var newRequestFromIncoming = (method, url, incoming) => {
|
|
139
|
+
const headerRecord = [];
|
|
140
|
+
const len = incoming.rawHeaders.length;
|
|
141
|
+
for (let i = 0; i < len; i += 2) {
|
|
142
|
+
headerRecord.push([incoming.rawHeaders[i], incoming.rawHeaders[i + 1]]);
|
|
143
|
+
}
|
|
144
|
+
const init = {
|
|
145
|
+
method,
|
|
146
|
+
headers: headerRecord
|
|
147
|
+
};
|
|
148
|
+
if (!(method === "GET" || method === "HEAD")) {
|
|
149
|
+
init.body = Readable.toWeb(incoming);
|
|
150
|
+
init.duplex = "half";
|
|
151
|
+
}
|
|
152
|
+
return new Request(url, init);
|
|
153
|
+
};
|
|
154
|
+
var getRequestCache = Symbol("getRequestCache");
|
|
155
|
+
var requestCache = Symbol("requestCache");
|
|
156
|
+
var incomingKey = Symbol("incomingKey");
|
|
157
|
+
var requestPrototype = {
|
|
158
|
+
get method() {
|
|
159
|
+
return this[incomingKey].method || "GET";
|
|
160
|
+
},
|
|
161
|
+
get url() {
|
|
162
|
+
return `http://${this[incomingKey].headers.host}${this[incomingKey].url}`;
|
|
163
|
+
},
|
|
164
|
+
[getRequestCache]() {
|
|
165
|
+
return this[requestCache] ||= newRequestFromIncoming(this.method, this.url, this[incomingKey]);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
[
|
|
169
|
+
"body",
|
|
170
|
+
"bodyUsed",
|
|
171
|
+
"cache",
|
|
172
|
+
"credentials",
|
|
173
|
+
"destination",
|
|
174
|
+
"headers",
|
|
175
|
+
"integrity",
|
|
176
|
+
"mode",
|
|
177
|
+
"redirect",
|
|
178
|
+
"referrer",
|
|
179
|
+
"referrerPolicy",
|
|
180
|
+
"signal"
|
|
181
|
+
].forEach((k) => {
|
|
182
|
+
Object.defineProperty(requestPrototype, k, {
|
|
183
|
+
get() {
|
|
184
|
+
return this[getRequestCache]()[k];
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
|
|
189
|
+
Object.defineProperty(requestPrototype, k, {
|
|
190
|
+
value: function() {
|
|
191
|
+
return this[getRequestCache]()[k]();
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
Object.setPrototypeOf(requestPrototype, global.Request.prototype);
|
|
196
|
+
var newRequest = (incoming) => {
|
|
197
|
+
const req = Object.create(requestPrototype);
|
|
198
|
+
req[incomingKey] = incoming;
|
|
199
|
+
return req;
|
|
200
|
+
};
|
|
62
201
|
|
|
63
202
|
// src/listener.ts
|
|
64
203
|
var regBuffer = /^no$/i;
|
|
65
204
|
var regContentType = /^(application\/json\b|text\/(?!event-stream\b))/i;
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
205
|
+
var handleFetchError = (e) => new Response(null, {
|
|
206
|
+
status: e instanceof Error && (e.name === "TimeoutError" || e.constructor.name === "TimeoutError") ? 504 : 500
|
|
207
|
+
});
|
|
208
|
+
var handleResponseError = (e, outgoing) => {
|
|
209
|
+
const err = e instanceof Error ? e : new Error("unknown error", { cause: e });
|
|
210
|
+
if (err.code === "ERR_STREAM_PREMATURE_CLOSE") {
|
|
211
|
+
console.info("The user aborted a request.");
|
|
212
|
+
} else {
|
|
213
|
+
console.error(e);
|
|
214
|
+
outgoing.destroy(err);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
var responseViaCache = (res, outgoing) => {
|
|
218
|
+
const [status, body, header] = res[cacheKey];
|
|
219
|
+
if (typeof body === "string") {
|
|
220
|
+
header["Content-Length"] = Buffer.byteLength(body);
|
|
221
|
+
outgoing.writeHead(status, header);
|
|
222
|
+
outgoing.end(body);
|
|
223
|
+
} else {
|
|
224
|
+
outgoing.writeHead(status, header);
|
|
225
|
+
return writeFromReadableStream(body, outgoing)?.catch(
|
|
226
|
+
(e) => handleResponseError(e, outgoing)
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
var responseViaResponseObject = async (res, outgoing) => {
|
|
231
|
+
if (res instanceof Promise) {
|
|
232
|
+
res = await res.catch(handleFetchError);
|
|
233
|
+
}
|
|
234
|
+
if (cacheKey in res) {
|
|
84
235
|
try {
|
|
85
|
-
|
|
236
|
+
return responseViaCache(res, outgoing);
|
|
86
237
|
} catch (e) {
|
|
87
|
-
|
|
88
|
-
if (e instanceof Error) {
|
|
89
|
-
if (e.name === "TimeoutError" || e.constructor.name === "TimeoutError") {
|
|
90
|
-
res = new Response(null, { status: 504 });
|
|
91
|
-
}
|
|
92
|
-
}
|
|
238
|
+
return handleResponseError(e, outgoing);
|
|
93
239
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
240
|
+
}
|
|
241
|
+
const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
|
|
242
|
+
if (res.body) {
|
|
243
|
+
try {
|
|
244
|
+
if (resHeaderRecord["transfer-encoding"] || resHeaderRecord["content-encoding"] || resHeaderRecord["content-length"] || // nginx buffering variant
|
|
245
|
+
resHeaderRecord["x-accel-buffering"] && regBuffer.test(resHeaderRecord["x-accel-buffering"]) || !regContentType.test(resHeaderRecord["content-type"])) {
|
|
246
|
+
outgoing.writeHead(res.status, resHeaderRecord);
|
|
247
|
+
await writeFromReadableStream(res.body, outgoing);
|
|
99
248
|
} else {
|
|
100
|
-
|
|
249
|
+
const buffer = await res.arrayBuffer();
|
|
250
|
+
resHeaderRecord["content-length"] = buffer.byteLength;
|
|
251
|
+
outgoing.writeHead(res.status, resHeaderRecord);
|
|
252
|
+
outgoing.end(new Uint8Array(buffer));
|
|
101
253
|
}
|
|
254
|
+
} catch (e) {
|
|
255
|
+
handleResponseError(e, outgoing);
|
|
102
256
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
} else {
|
|
123
|
-
console.error(e);
|
|
124
|
-
outgoing.destroy(err);
|
|
125
|
-
}
|
|
257
|
+
} else {
|
|
258
|
+
outgoing.writeHead(res.status, resHeaderRecord);
|
|
259
|
+
outgoing.end();
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
var getRequestListener = (fetchCallback) => {
|
|
263
|
+
return (incoming, outgoing) => {
|
|
264
|
+
let res;
|
|
265
|
+
const req = newRequest(incoming);
|
|
266
|
+
try {
|
|
267
|
+
res = fetchCallback(req);
|
|
268
|
+
if (cacheKey in res) {
|
|
269
|
+
return responseViaCache(res, outgoing);
|
|
270
|
+
}
|
|
271
|
+
} catch (e) {
|
|
272
|
+
if (!res) {
|
|
273
|
+
res = handleFetchError(e);
|
|
274
|
+
} else {
|
|
275
|
+
return handleResponseError(e, outgoing);
|
|
126
276
|
}
|
|
127
|
-
} else {
|
|
128
|
-
outgoing.writeHead(res.status, resHeaderRecord);
|
|
129
|
-
outgoing.end();
|
|
130
277
|
}
|
|
278
|
+
return responseViaResponseObject(res, outgoing);
|
|
131
279
|
};
|
|
132
280
|
};
|
|
133
281
|
|
package/dist/types.d.mts
CHANGED
|
@@ -2,29 +2,29 @@ import { Server, ServerOptions as ServerOptions$1, createServer } from 'node:htt
|
|
|
2
2
|
import { ServerOptions as ServerOptions$2, createServer as createServer$1 } from 'node:https';
|
|
3
3
|
import { Http2Server, Http2SecureServer, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer } from 'node:http2';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type FetchCallback = (request: Request) => Promise<unknown> | unknown;
|
|
6
|
+
type NextHandlerOption = {
|
|
7
7
|
fetch: FetchCallback;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
type ServerType = Server | Http2Server | Http2SecureServer;
|
|
10
|
+
type createHttpOptions = {
|
|
11
11
|
serverOptions?: ServerOptions$1;
|
|
12
12
|
createServer?: typeof createServer;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
type createHttpsOptions = {
|
|
15
15
|
serverOptions?: ServerOptions$2;
|
|
16
16
|
createServer?: typeof createServer$1;
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
type createHttp2Options = {
|
|
19
19
|
serverOptions?: ServerOptions$3;
|
|
20
20
|
createServer?: typeof createServer$2;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
type createSecureHttp2Options = {
|
|
23
23
|
serverOptions?: SecureServerOptions;
|
|
24
24
|
createServer?: typeof createSecureServer;
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
type ServerOptions = createHttpOptions | createHttpsOptions | createHttp2Options | createSecureHttp2Options;
|
|
27
|
+
type Options = {
|
|
28
28
|
fetch: FetchCallback;
|
|
29
29
|
port?: number;
|
|
30
30
|
hostname?: string;
|
package/dist/types.d.ts
CHANGED
|
@@ -2,29 +2,29 @@ import { Server, ServerOptions as ServerOptions$1, createServer } from 'node:htt
|
|
|
2
2
|
import { ServerOptions as ServerOptions$2, createServer as createServer$1 } from 'node:https';
|
|
3
3
|
import { Http2Server, Http2SecureServer, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer } from 'node:http2';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type FetchCallback = (request: Request) => Promise<unknown> | unknown;
|
|
6
|
+
type NextHandlerOption = {
|
|
7
7
|
fetch: FetchCallback;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
type ServerType = Server | Http2Server | Http2SecureServer;
|
|
10
|
+
type createHttpOptions = {
|
|
11
11
|
serverOptions?: ServerOptions$1;
|
|
12
12
|
createServer?: typeof createServer;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
type createHttpsOptions = {
|
|
15
15
|
serverOptions?: ServerOptions$2;
|
|
16
16
|
createServer?: typeof createServer$1;
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
type createHttp2Options = {
|
|
19
19
|
serverOptions?: ServerOptions$3;
|
|
20
20
|
createServer?: typeof createServer$2;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
type createSecureHttp2Options = {
|
|
23
23
|
serverOptions?: SecureServerOptions;
|
|
24
24
|
createServer?: typeof createSecureServer;
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
type ServerOptions = createHttpOptions | createHttpsOptions | createHttp2Options | createSecureHttp2Options;
|
|
27
|
+
type Options = {
|
|
28
28
|
fetch: FetchCallback;
|
|
29
29
|
port?: number;
|
|
30
30
|
hostname?: string;
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Writable } from 'node:stream';
|
|
2
|
+
import { OutgoingHttpHeaders } from 'node:http';
|
|
2
3
|
|
|
3
4
|
declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<undefined> | undefined;
|
|
5
|
+
declare const buildOutgoingHttpHeaders: (headers: Headers) => OutgoingHttpHeaders;
|
|
4
6
|
|
|
5
|
-
export { writeFromReadableStream };
|
|
7
|
+
export { buildOutgoingHttpHeaders, writeFromReadableStream };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Writable } from 'node:stream';
|
|
2
|
+
import { OutgoingHttpHeaders } from 'node:http';
|
|
2
3
|
|
|
3
4
|
declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<undefined> | undefined;
|
|
5
|
+
declare const buildOutgoingHttpHeaders: (headers: Headers) => OutgoingHttpHeaders;
|
|
4
6
|
|
|
5
|
-
export { writeFromReadableStream };
|
|
7
|
+
export { buildOutgoingHttpHeaders, writeFromReadableStream };
|
package/dist/utils.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/utils.ts
|
|
21
21
|
var utils_exports = {};
|
|
22
22
|
__export(utils_exports, {
|
|
23
|
+
buildOutgoingHttpHeaders: () => buildOutgoingHttpHeaders,
|
|
23
24
|
writeFromReadableStream: () => writeFromReadableStream
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(utils_exports);
|
|
@@ -61,7 +62,24 @@ function writeFromReadableStream(stream, writable) {
|
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
}
|
|
65
|
+
var buildOutgoingHttpHeaders = (headers) => {
|
|
66
|
+
const res = {};
|
|
67
|
+
const cookies = [];
|
|
68
|
+
for (const [k, v] of headers) {
|
|
69
|
+
if (k === "set-cookie") {
|
|
70
|
+
cookies.push(v);
|
|
71
|
+
} else {
|
|
72
|
+
res[k] = v;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (cookies.length > 0) {
|
|
76
|
+
res["set-cookie"] = cookies;
|
|
77
|
+
}
|
|
78
|
+
res["content-type"] ??= "text/plain;charset=UTF-8";
|
|
79
|
+
return res;
|
|
80
|
+
};
|
|
64
81
|
// Annotate the CommonJS export names for ESM import in node:
|
|
65
82
|
0 && (module.exports = {
|
|
83
|
+
buildOutgoingHttpHeaders,
|
|
66
84
|
writeFromReadableStream
|
|
67
85
|
});
|
package/dist/utils.mjs
CHANGED
|
@@ -37,6 +37,23 @@ function writeFromReadableStream(stream, writable) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
var buildOutgoingHttpHeaders = (headers) => {
|
|
41
|
+
const res = {};
|
|
42
|
+
const cookies = [];
|
|
43
|
+
for (const [k, v] of headers) {
|
|
44
|
+
if (k === "set-cookie") {
|
|
45
|
+
cookies.push(v);
|
|
46
|
+
} else {
|
|
47
|
+
res[k] = v;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (cookies.length > 0) {
|
|
51
|
+
res["set-cookie"] = cookies;
|
|
52
|
+
}
|
|
53
|
+
res["content-type"] ??= "text/plain;charset=UTF-8";
|
|
54
|
+
return res;
|
|
55
|
+
};
|
|
40
56
|
export {
|
|
57
|
+
buildOutgoingHttpHeaders,
|
|
41
58
|
writeFromReadableStream
|
|
42
59
|
};
|
package/dist/vercel.d.mts
CHANGED
|
@@ -2,6 +2,6 @@ import * as http2 from 'http2';
|
|
|
2
2
|
import * as http from 'http';
|
|
3
3
|
import { Hono } from 'hono';
|
|
4
4
|
|
|
5
|
-
declare const handle: (app: Hono<any, any, any>) => (incoming: http.IncomingMessage | http2.Http2ServerRequest, outgoing: http.ServerResponse<http.IncomingMessage> | http2.Http2ServerResponse) => Promise<void>;
|
|
5
|
+
declare const handle: (app: Hono<any, any, any>) => (incoming: http.IncomingMessage | http2.Http2ServerRequest, outgoing: http.ServerResponse<http.IncomingMessage> | http2.Http2ServerResponse) => void | Promise<void>;
|
|
6
6
|
|
|
7
7
|
export { handle };
|
package/dist/vercel.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import * as http2 from 'http2';
|
|
|
2
2
|
import * as http from 'http';
|
|
3
3
|
import { Hono } from 'hono';
|
|
4
4
|
|
|
5
|
-
declare const handle: (app: Hono<any, any, any>) => (incoming: http.IncomingMessage | http2.Http2ServerRequest, outgoing: http.ServerResponse<http.IncomingMessage> | http2.Http2ServerResponse) => Promise<void>;
|
|
5
|
+
declare const handle: (app: Hono<any, any, any>) => (incoming: http.IncomingMessage | http2.Http2ServerRequest, outgoing: http.ServerResponse<http.IncomingMessage> | http2.Http2ServerResponse) => void | Promise<void>;
|
|
6
6
|
|
|
7
7
|
export { handle };
|