webhoster 0.3.4 → 0.3.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.
Files changed (127) hide show
  1. package/data/custom-types.js +14 -14
  2. package/package.json +12 -1
  3. package/types/data/CookieObject.d.ts +34 -0
  4. package/types/data/CookieObject.d.ts.map +1 -0
  5. package/types/data/custom-types.d.ts +112 -0
  6. package/types/data/custom-types.d.ts.map +1 -0
  7. package/types/errata/socketio.d.ts +11 -0
  8. package/types/errata/socketio.d.ts.map +1 -0
  9. package/types/examples/starter.d.ts +2 -0
  10. package/types/examples/starter.d.ts.map +1 -0
  11. package/types/helpers/HeadersParser.d.ts +27 -0
  12. package/types/helpers/HeadersParser.d.ts.map +1 -0
  13. package/types/helpers/HttpListener.d.ts +84 -0
  14. package/types/helpers/HttpListener.d.ts.map +1 -0
  15. package/types/helpers/RequestHeaders.d.ts +25 -0
  16. package/types/helpers/RequestHeaders.d.ts.map +1 -0
  17. package/types/helpers/RequestReader.d.ts +52 -0
  18. package/types/helpers/RequestReader.d.ts.map +1 -0
  19. package/types/helpers/ResponseHeaders.d.ts +126 -0
  20. package/types/helpers/ResponseHeaders.d.ts.map +1 -0
  21. package/types/helpers/index.d.ts +6 -0
  22. package/types/helpers/index.d.ts.map +1 -0
  23. package/types/lib/HttpHandler.d.ts +79 -0
  24. package/types/lib/HttpHandler.d.ts.map +1 -0
  25. package/types/lib/HttpRequest.d.ts +175 -0
  26. package/types/lib/HttpRequest.d.ts.map +1 -0
  27. package/types/lib/HttpResponse.d.ts +117 -0
  28. package/types/lib/HttpResponse.d.ts.map +1 -0
  29. package/types/lib/HttpTransaction.d.ts +114 -0
  30. package/types/lib/HttpTransaction.d.ts.map +1 -0
  31. package/types/middleware/AutoHeadersMiddleware.d.ts +27 -0
  32. package/types/middleware/AutoHeadersMiddleware.d.ts.map +1 -0
  33. package/types/middleware/CORSMiddleware.d.ts +65 -0
  34. package/types/middleware/CORSMiddleware.d.ts.map +1 -0
  35. package/types/middleware/CaseInsensitiveHeadersMiddleware.d.ts +27 -0
  36. package/types/middleware/CaseInsensitiveHeadersMiddleware.d.ts.map +1 -0
  37. package/types/middleware/ContentDecoderMiddleware.d.ts +17 -0
  38. package/types/middleware/ContentDecoderMiddleware.d.ts.map +1 -0
  39. package/types/middleware/ContentEncoderMiddleware.d.ts +48 -0
  40. package/types/middleware/ContentEncoderMiddleware.d.ts.map +1 -0
  41. package/types/middleware/ContentLengthMiddleware.d.ts +38 -0
  42. package/types/middleware/ContentLengthMiddleware.d.ts.map +1 -0
  43. package/types/middleware/HashMiddleware.d.ts +28 -0
  44. package/types/middleware/HashMiddleware.d.ts.map +1 -0
  45. package/types/middleware/HeadMethodMiddleware.d.ts +12 -0
  46. package/types/middleware/HeadMethodMiddleware.d.ts.map +1 -0
  47. package/types/middleware/MethodMiddleware.d.ts +40 -0
  48. package/types/middleware/MethodMiddleware.d.ts.map +1 -0
  49. package/types/middleware/PathMiddleware.d.ts +81 -0
  50. package/types/middleware/PathMiddleware.d.ts.map +1 -0
  51. package/types/middleware/ReadFormData.d.ts +7 -0
  52. package/types/middleware/ReadFormData.d.ts.map +1 -0
  53. package/types/middleware/SendJsonMiddleware.d.ts +51 -0
  54. package/types/middleware/SendJsonMiddleware.d.ts.map +1 -0
  55. package/types/middleware/SendStringMiddleware.d.ts +35 -0
  56. package/types/middleware/SendStringMiddleware.d.ts.map +1 -0
  57. package/types/templates/starter.d.ts +15 -0
  58. package/types/templates/starter.d.ts.map +1 -0
  59. package/types/utils/AsyncObject.d.ts +38 -0
  60. package/types/utils/AsyncObject.d.ts.map +1 -0
  61. package/types/utils/CaseInsensitiveObject.d.ts +9 -0
  62. package/types/utils/CaseInsensitiveObject.d.ts.map +1 -0
  63. package/types/utils/function.d.ts +2 -0
  64. package/types/utils/function.d.ts.map +1 -0
  65. package/types/utils/headers.d.ts +7 -0
  66. package/types/utils/headers.d.ts.map +1 -0
  67. package/types/utils/qualityValues.d.ts +12 -0
  68. package/types/utils/qualityValues.d.ts.map +1 -0
  69. package/types/utils/stream.d.ts +6 -0
  70. package/types/utils/stream.d.ts.map +1 -0
  71. package/.eslintrc.json +0 -96
  72. package/.github/FUNDING.yml +0 -4
  73. package/.github/copilot-instructions.md +0 -100
  74. package/.github/workflows/publish.yml +0 -29
  75. package/.github/workflows/test-matrix.yml +0 -37
  76. package/.test/benchmark.js +0 -28
  77. package/.test/constants.js +0 -4
  78. package/.test/cookietester.js +0 -19
  79. package/.test/http2server.js +0 -35
  80. package/.test/httpserver.js +0 -32
  81. package/.test/index.js +0 -498
  82. package/.test/multipromise.js +0 -32
  83. package/.test/tls.js +0 -75
  84. package/.test/urlencoded.js +0 -54
  85. package/.vscode/launch.json +0 -35
  86. package/.vscode/settings.json +0 -5
  87. package/CHANGELOG.md +0 -10
  88. package/CODE_OF_CONDUCT.md +0 -76
  89. package/data/middleware.d.ts +0 -14
  90. package/examples/starter.js +0 -11
  91. package/jsconfig.json +0 -12
  92. package/polyfill/FormData.js +0 -164
  93. package/rollup.config.js +0 -8
  94. package/scripts/check-teapot.mjs +0 -40
  95. package/scripts/test-all-sync.sh +0 -6
  96. package/scripts/test-all.sh +0 -7
  97. package/test/fixtures/stream.js +0 -68
  98. package/test/helpers/HttpListener/construct.js +0 -18
  99. package/test/helpers/HttpListener/customOptions.js +0 -22
  100. package/test/helpers/HttpListener/doubleCreate.js +0 -40
  101. package/test/helpers/HttpListener/events.js +0 -77
  102. package/test/helpers/HttpListener/http.js +0 -31
  103. package/test/helpers/HttpListener/http2.js +0 -41
  104. package/test/helpers/HttpListener/https.js +0 -38
  105. package/test/helpers/HttpListener/startAll.js +0 -31
  106. package/test/helpers/HttpListener/stopNotStarted.js +0 -23
  107. package/test/lib/HttpHandler/class.js +0 -8
  108. package/test/lib/HttpHandler/handleRequest.js +0 -11
  109. package/test/lib/HttpHandler/middleware.js +0 -941
  110. package/test/lib/HttpHandler/parse.js +0 -41
  111. package/test/lib/HttpRequest/class.js +0 -8
  112. package/test/lib/HttpRequest/downstream.js +0 -171
  113. package/test/lib/HttpRequest/properties.js +0 -101
  114. package/test/lib/HttpRequest/read.js +0 -518
  115. package/test/lib/HttpResponse/async-iterable-middleware.js +0 -37
  116. package/test/lib/HttpResponse/async-iterable.js +0 -31
  117. package/test/lib/HttpResponse/class.js +0 -8
  118. package/test/lib/HttpResponse/properties.js +0 -59
  119. package/test/lib/HttpResponse/send.js +0 -275
  120. package/test/lib/HttpTransaction/class.js +0 -8
  121. package/test/lib/HttpTransaction/ping.js +0 -50
  122. package/test/lib/HttpTransaction/push.js +0 -89
  123. package/test/middleware/SendJsonMiddleware.js +0 -222
  124. package/test/sanity.js +0 -10
  125. package/test/templates/error-teapot.js +0 -47
  126. package/test/templates/starter.js +0 -93
  127. package/tsconfig.json +0 -29
@@ -1,38 +0,0 @@
1
- import { connect as tlsConnect } from 'node:tls';
2
-
3
- import test from 'ava';
4
-
5
- import HttpListener from '../../../helpers/HttpListener.js';
6
-
7
- const key = process.env.TEST_SSL_KEY;
8
- const cert = process.env.TEST_SSL_CERT;
9
- const haveCerts = key && cert;
10
-
11
- const testFn = haveCerts ? test : test.skip;
12
-
13
- testFn('HttpListener.startHttpsServer() and stopHttpsServer() work', async (t) => {
14
- const tlsOptions = { key, cert };
15
- const listener = new HttpListener({ securePort: 0, useHttps: true, tlsOptions });
16
- const server = await listener.startHttpsServer();
17
- t.truthy(server);
18
- await listener.stopHttpsServer();
19
- t.pass();
20
- });
21
-
22
- testFn('HttpListener HTTPS server closes idle socket after keepAliveTimeout', async (t) => {
23
- const tlsOptions = { key, cert };
24
- const listener = new HttpListener({ securePort: 0, useHttps: true, tlsOptions });
25
- await listener.startHttpsServer();
26
- const server = listener.httpsServer;
27
- server.setTimeout(1000);
28
- const address = server.address();
29
- const port = typeof address === 'object' && address ? address.port : address;
30
- let destroyed = false;
31
- const socket = tlsConnect({ port: Number(port), host: '127.0.0.1', rejectUnauthorized: false }, () => {
32
- // Do not send any data, just keep connection open
33
- });
34
- socket.on('close', () => { destroyed = true; });
35
- await new Promise((resolve) => setTimeout(resolve, 2000));
36
- t.true(destroyed, 'TLS socket should be destroyed after keepAliveTimeout');
37
- await listener.stopHttpsServer();
38
- });
@@ -1,31 +0,0 @@
1
- import test from 'ava';
2
-
3
- import HttpListener from '../../../helpers/HttpListener.js';
4
-
5
- // Test startAll and stopAll with all modes enabled (HTTP, HTTPS, HTTP/2)
6
-
7
- const key = process.env.TEST_SSL_KEY;
8
- const cert = process.env.TEST_SSL_CERT;
9
- const haveCerts = !!key && !!cert;
10
-
11
- test('HttpListener.startAll() and stopAll() work (all modes)', async (t) => {
12
- const listener = new HttpListener({
13
- insecurePort: 0,
14
- securePort: 0,
15
- useHttp: true,
16
- useHttps: haveCerts,
17
- useHttp2: haveCerts,
18
- tlsOptions: haveCerts ? { key, cert } : undefined,
19
- });
20
- const [http, https, http2] = await listener.startAll();
21
- t.truthy(http);
22
- if (haveCerts) {
23
- t.truthy(https);
24
- t.truthy(http2);
25
- } else {
26
- t.is(https, null);
27
- t.is(http2, null);
28
- }
29
- await listener.stopAll();
30
- t.pass();
31
- });
@@ -1,23 +0,0 @@
1
- import test from 'ava';
2
- import HttpListener from '../../../helpers/HttpListener.js';
3
-
4
- // Test stop methods when servers are not started (should resolve, not throw)
5
- test('stopHttpServer resolves if not started', async t => {
6
- const listener = new HttpListener();
7
- await t.notThrowsAsync(() => listener.stopHttpServer());
8
- });
9
-
10
- test('stopHttpsServer resolves if not started', async t => {
11
- const listener = new HttpListener({ useHttps: true });
12
- await t.notThrowsAsync(() => listener.stopHttpsServer());
13
- });
14
-
15
- test('stopHttp2Server resolves if not started', async t => {
16
- const listener = new HttpListener({ useHttp2: true });
17
- await t.notThrowsAsync(() => listener.stopHttp2Server());
18
- });
19
-
20
- test('stopAll resolves if nothing started', async t => {
21
- const listener = new HttpListener({ useHttp: false, useHttps: false, useHttp2: false });
22
- await t.notThrowsAsync(() => listener.stopAll());
23
- });
@@ -1,8 +0,0 @@
1
- import test from 'ava';
2
-
3
- import HttpHandler from '../../../lib/HttpHandler.js';
4
-
5
- test('new HttpHandler()', (t) => {
6
- const instance = new HttpHandler({});
7
- t.assert(instance instanceof HttpHandler);
8
- });
@@ -1,11 +0,0 @@
1
- import test from 'ava';
2
- import { PassThrough, Readable, Writable } from 'node:stream';
3
-
4
- import HttpHandler from '../../../lib/HttpHandler.js';
5
- import HttpRequest from '../../../lib/HttpRequest.js';
6
- import HttpResponse from '../../../lib/HttpResponse.js';
7
-
8
- test('HttpHandler.handleRequest()', async (t) => {
9
-
10
- t.pass();
11
- });