@zukhruf/testing 0.6.9 → 0.6.10
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-server.d.ts","sourceRoot":"","sources":["../../src/http/http-server.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,cAAc,EAEpB,MAAM,WAAW,CAAC;AAEnB;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,cAAc,KACrB,OAAO,CAAC;AAEb,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,yEAAyE;AACzE,qBAAa,UAAU;IACf,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"http-server.d.ts","sourceRoot":"","sources":["../../src/http/http-server.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,cAAc,EAEpB,MAAM,WAAW,CAAC;AAEnB;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,cAAc,KACrB,OAAO,CAAC;AAEb,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,yEAAyE;AACzE,qBAAa,UAAU;IACf,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;CA2B7D"}
|
package/dist/http/http-server.js
CHANGED
|
@@ -5,14 +5,20 @@ import { createServer, } from 'node:http';
|
|
|
5
5
|
export class HttpServer {
|
|
6
6
|
async start(handler) {
|
|
7
7
|
await using resources = new AsyncDisposableStack();
|
|
8
|
-
const server =
|
|
9
|
-
|
|
8
|
+
const server = createServer((request, response) => {
|
|
9
|
+
void handler(request, response);
|
|
10
|
+
});
|
|
11
|
+
const listening = once(server, 'listening');
|
|
12
|
+
server.listen(0, '127.0.0.1');
|
|
13
|
+
await listening;
|
|
10
14
|
resources.defer(async () => {
|
|
11
15
|
const closed = server[Symbol.asyncDispose]();
|
|
12
16
|
server.closeAllConnections();
|
|
13
17
|
await closed;
|
|
14
18
|
});
|
|
15
|
-
const
|
|
19
|
+
const address = server.address();
|
|
20
|
+
assert(address && typeof address === 'object');
|
|
21
|
+
const origin = `http://127.0.0.1:${address.port}`;
|
|
16
22
|
const owned = resources.move();
|
|
17
23
|
const cleanup = () => owned.disposeAsync();
|
|
18
24
|
return {
|
|
@@ -23,19 +29,4 @@ export class HttpServer {
|
|
|
23
29
|
};
|
|
24
30
|
}
|
|
25
31
|
}
|
|
26
|
-
function serve(handler) {
|
|
27
|
-
return createServer((request, response) => {
|
|
28
|
-
void handler(request, response);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
async function listen(server) {
|
|
32
|
-
const listening = once(server, 'listening');
|
|
33
|
-
server.listen(0, '127.0.0.1');
|
|
34
|
-
await listening;
|
|
35
|
-
}
|
|
36
|
-
function originOf(server) {
|
|
37
|
-
const address = server.address();
|
|
38
|
-
assert(address && typeof address === 'object');
|
|
39
|
-
return `http://127.0.0.1:${address.port}`;
|
|
40
|
-
}
|
|
41
32
|
//# sourceMappingURL=http-server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-server.js","sourceRoot":"","sources":["../../src/http/http-server.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CA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/C,MAAM,MAAM,GAAG,oBAAoB,OAAO,CAAC,IAAI,EAAE,CAAC;QAClD,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;QAE3C,OAAO;YACL,MAAM;YACN,MAAM;YACN,OAAO;YACP,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO;SAC/B,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/testing",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"description": "Disposable fixtures for integration tests: Docker containers, database servers, SQLite and DuckDB databases, HTTP servers, streams, temporary directories and intercepted requests. Node's global setup and teardown remove what a killed test run left behind.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
"pg": "^8.23.1"
|
|
145
145
|
},
|
|
146
146
|
"dependencies": {
|
|
147
|
-
"@zukhruf/docker": "^0.6.
|
|
147
|
+
"@zukhruf/docker": "^0.6.10",
|
|
148
148
|
"nano-spawn": "^2.1.0",
|
|
149
149
|
"p-memoize": "^8.0.0",
|
|
150
150
|
"p-retry": "^8.0.1"
|