@whatwg-node/server 0.8.5 → 0.8.6
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/cjs/uwebsockets.js +11 -10
- package/esm/uwebsockets.js +11 -10
- package/package.json +1 -2
- package/typings/uwebsockets.d.cts +2 -0
- package/typings/uwebsockets.d.ts +2 -0
package/cjs/uwebsockets.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sendResponseToUwsOpts = exports.getRequestFromUWSRequest = exports.isUWSResponse = void 0;
|
|
4
|
-
const repeater_1 = require("@repeaterjs/repeater");
|
|
5
4
|
function isUWSResponse(res) {
|
|
6
5
|
return typeof res === 'object' && typeof res.onData === 'function';
|
|
7
6
|
}
|
|
@@ -10,14 +9,16 @@ function getRequestFromUWSRequest({ req, res, fetchAPI }) {
|
|
|
10
9
|
let body;
|
|
11
10
|
const method = req.getMethod();
|
|
12
11
|
if (method !== 'get' && method !== 'head') {
|
|
13
|
-
body = new
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
body = new fetchAPI.ReadableStream({});
|
|
13
|
+
const readable = body.readable;
|
|
14
|
+
res.onAborted(() => {
|
|
15
|
+
readable.push(null);
|
|
16
|
+
});
|
|
17
|
+
res.onData(function (chunk, isLast) {
|
|
18
|
+
readable.push(Buffer.from(chunk, 0, chunk.byteLength));
|
|
19
|
+
if (isLast) {
|
|
20
|
+
readable.push(null);
|
|
21
|
+
}
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
const headers = {};
|
|
@@ -58,7 +59,7 @@ async function sendResponseToUwsOpts({ res, response }) {
|
|
|
58
59
|
});
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
61
|
-
for await (const chunk of response.body
|
|
62
|
+
for await (const chunk of response.body) {
|
|
62
63
|
if (resAborted) {
|
|
63
64
|
return;
|
|
64
65
|
}
|
package/esm/uwebsockets.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Repeater } from '@repeaterjs/repeater';
|
|
2
1
|
export function isUWSResponse(res) {
|
|
3
2
|
return typeof res === 'object' && typeof res.onData === 'function';
|
|
4
3
|
}
|
|
@@ -6,14 +5,16 @@ export function getRequestFromUWSRequest({ req, res, fetchAPI }) {
|
|
|
6
5
|
let body;
|
|
7
6
|
const method = req.getMethod();
|
|
8
7
|
if (method !== 'get' && method !== 'head') {
|
|
9
|
-
body = new
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
body = new fetchAPI.ReadableStream({});
|
|
9
|
+
const readable = body.readable;
|
|
10
|
+
res.onAborted(() => {
|
|
11
|
+
readable.push(null);
|
|
12
|
+
});
|
|
13
|
+
res.onData(function (chunk, isLast) {
|
|
14
|
+
readable.push(Buffer.from(chunk, 0, chunk.byteLength));
|
|
15
|
+
if (isLast) {
|
|
16
|
+
readable.push(null);
|
|
17
|
+
}
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
20
|
const headers = {};
|
|
@@ -53,7 +54,7 @@ export async function sendResponseToUwsOpts({ res, response }) {
|
|
|
53
54
|
});
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
|
-
for await (const chunk of response.body
|
|
57
|
+
for await (const chunk of response.body) {
|
|
57
58
|
if (resAborted) {
|
|
58
59
|
return;
|
|
59
60
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whatwg-node/server",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"description": "Fetch API compliant HTTP Server adapter",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@repeaterjs/repeater": "^3.0.4",
|
|
8
7
|
"@whatwg-node/fetch": "^0.9.3",
|
|
9
8
|
"tslib": "^2.3.1"
|
|
10
9
|
},
|
|
@@ -4,6 +4,7 @@ export interface UWSRequest {
|
|
|
4
4
|
forEach(callback: (key: string, value: string) => void): void;
|
|
5
5
|
getUrl(): string;
|
|
6
6
|
getHeader(key: string): string | undefined;
|
|
7
|
+
setYield(y: boolean): void;
|
|
7
8
|
}
|
|
8
9
|
export interface UWSResponse {
|
|
9
10
|
onData(callback: (chunk: ArrayBuffer, isLast: boolean) => void): void;
|
|
@@ -11,6 +12,7 @@ export interface UWSResponse {
|
|
|
11
12
|
writeStatus(status: string): void;
|
|
12
13
|
writeHeader(key: string, value: string): void;
|
|
13
14
|
end(body?: any): void;
|
|
15
|
+
close(): void;
|
|
14
16
|
write(body: any): boolean;
|
|
15
17
|
cork(callback: () => void): void;
|
|
16
18
|
}
|
package/typings/uwebsockets.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export interface UWSRequest {
|
|
|
4
4
|
forEach(callback: (key: string, value: string) => void): void;
|
|
5
5
|
getUrl(): string;
|
|
6
6
|
getHeader(key: string): string | undefined;
|
|
7
|
+
setYield(y: boolean): void;
|
|
7
8
|
}
|
|
8
9
|
export interface UWSResponse {
|
|
9
10
|
onData(callback: (chunk: ArrayBuffer, isLast: boolean) => void): void;
|
|
@@ -11,6 +12,7 @@ export interface UWSResponse {
|
|
|
11
12
|
writeStatus(status: string): void;
|
|
12
13
|
writeHeader(key: string, value: string): void;
|
|
13
14
|
end(body?: any): void;
|
|
15
|
+
close(): void;
|
|
14
16
|
write(body: any): boolean;
|
|
15
17
|
cork(callback: () => void): void;
|
|
16
18
|
}
|