webhoster 0.3.3 → 0.3.5
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/README.md +4 -4
- package/data/CookieObject.js +1 -1
- package/{types/index.js → data/custom-types.js} +1 -1
- package/{types/typings.d.ts → data/middleware.d.ts} +1 -1
- package/helpers/RequestReader.js +1 -1
- package/helpers/ResponseHeaders.js +9 -10
- package/lib/HttpHandler.js +4 -4
- package/lib/HttpRequest.js +2 -2
- package/lib/HttpResponse.js +2 -2
- package/lib/HttpTransaction.js +2 -2
- package/middleware/AutoHeadersMiddleware.js +2 -2
- package/middleware/CORSMiddleware.js +3 -3
- package/middleware/CaseInsensitiveHeadersMiddleware.js +2 -2
- package/middleware/ContentDecoderMiddleware.js +1 -1
- package/middleware/ContentEncoderMiddleware.js +2 -2
- package/middleware/ContentLengthMiddleware.js +2 -2
- package/middleware/HashMiddleware.js +2 -2
- package/middleware/HeadMethodMiddleware.js +3 -3
- package/middleware/MethodMiddleware.js +3 -3
- package/middleware/PathMiddleware.js +4 -4
- package/middleware/ReadFormData.js +1 -1
- package/middleware/SendJsonMiddleware.js +4 -4
- package/middleware/SendStringMiddleware.js +3 -3
- package/package.json +21 -4
- package/templates/starter.js +2 -2
- package/types/data/CookieObject.d.ts +34 -0
- package/types/data/CookieObject.d.ts.map +1 -0
- package/types/data/custom-types.d.ts +111 -0
- package/types/data/custom-types.d.ts.map +1 -0
- package/types/errata/socketio.d.ts +11 -0
- package/types/errata/socketio.d.ts.map +1 -0
- package/types/examples/starter.d.ts +2 -0
- package/types/examples/starter.d.ts.map +1 -0
- package/types/helpers/HeadersParser.d.ts +27 -0
- package/types/helpers/HeadersParser.d.ts.map +1 -0
- package/types/helpers/HttpListener.d.ts +84 -0
- package/types/helpers/HttpListener.d.ts.map +1 -0
- package/types/helpers/RequestHeaders.d.ts +25 -0
- package/types/helpers/RequestHeaders.d.ts.map +1 -0
- package/types/helpers/RequestReader.d.ts +52 -0
- package/types/helpers/RequestReader.d.ts.map +1 -0
- package/types/helpers/ResponseHeaders.d.ts +126 -0
- package/types/helpers/ResponseHeaders.d.ts.map +1 -0
- package/types/helpers/index.d.ts +6 -0
- package/types/helpers/index.d.ts.map +1 -0
- package/types/lib/HttpHandler.d.ts +79 -0
- package/types/lib/HttpHandler.d.ts.map +1 -0
- package/types/lib/HttpRequest.d.ts +175 -0
- package/types/lib/HttpRequest.d.ts.map +1 -0
- package/types/lib/HttpResponse.d.ts +117 -0
- package/types/lib/HttpResponse.d.ts.map +1 -0
- package/types/lib/HttpTransaction.d.ts +114 -0
- package/types/lib/HttpTransaction.d.ts.map +1 -0
- package/types/middleware/AutoHeadersMiddleware.d.ts +27 -0
- package/types/middleware/AutoHeadersMiddleware.d.ts.map +1 -0
- package/types/middleware/CORSMiddleware.d.ts +65 -0
- package/types/middleware/CORSMiddleware.d.ts.map +1 -0
- package/types/middleware/CaseInsensitiveHeadersMiddleware.d.ts +27 -0
- package/types/middleware/CaseInsensitiveHeadersMiddleware.d.ts.map +1 -0
- package/types/middleware/ContentDecoderMiddleware.d.ts +17 -0
- package/types/middleware/ContentDecoderMiddleware.d.ts.map +1 -0
- package/types/middleware/ContentEncoderMiddleware.d.ts +48 -0
- package/types/middleware/ContentEncoderMiddleware.d.ts.map +1 -0
- package/types/middleware/ContentLengthMiddleware.d.ts +38 -0
- package/types/middleware/ContentLengthMiddleware.d.ts.map +1 -0
- package/types/middleware/HashMiddleware.d.ts +28 -0
- package/types/middleware/HashMiddleware.d.ts.map +1 -0
- package/types/middleware/HeadMethodMiddleware.d.ts +12 -0
- package/types/middleware/HeadMethodMiddleware.d.ts.map +1 -0
- package/types/middleware/MethodMiddleware.d.ts +40 -0
- package/types/middleware/MethodMiddleware.d.ts.map +1 -0
- package/types/middleware/PathMiddleware.d.ts +81 -0
- package/types/middleware/PathMiddleware.d.ts.map +1 -0
- package/types/middleware/ReadFormData.d.ts +7 -0
- package/types/middleware/ReadFormData.d.ts.map +1 -0
- package/types/middleware/SendJsonMiddleware.d.ts +51 -0
- package/types/middleware/SendJsonMiddleware.d.ts.map +1 -0
- package/types/middleware/SendStringMiddleware.d.ts +35 -0
- package/types/middleware/SendStringMiddleware.d.ts.map +1 -0
- package/types/templates/starter.d.ts +15 -0
- package/types/templates/starter.d.ts.map +1 -0
- package/types/utils/AsyncObject.d.ts +38 -0
- package/types/utils/AsyncObject.d.ts.map +1 -0
- package/types/utils/CaseInsensitiveObject.d.ts +9 -0
- package/types/utils/CaseInsensitiveObject.d.ts.map +1 -0
- package/types/utils/function.d.ts +2 -0
- package/types/utils/function.d.ts.map +1 -0
- package/types/utils/headers.d.ts +7 -0
- package/types/utils/headers.d.ts.map +1 -0
- package/types/utils/qualityValues.d.ts +12 -0
- package/types/utils/qualityValues.d.ts.map +1 -0
- package/types/utils/stream.d.ts +6 -0
- package/types/utils/stream.d.ts.map +1 -0
- package/utils/headers.js +1 -1
- package/.eslintrc.json +0 -96
- package/.github/FUNDING.yml +0 -4
- package/.github/copilot-instructions.md +0 -100
- package/.github/workflows/publish.yml +0 -29
- package/.github/workflows/test-matrix.yml +0 -37
- package/.test/benchmark.js +0 -28
- package/.test/constants.js +0 -4
- package/.test/cookietester.js +0 -19
- package/.test/http2server.js +0 -35
- package/.test/httpserver.js +0 -32
- package/.test/index.js +0 -498
- package/.test/multipromise.js +0 -32
- package/.test/tls.js +0 -75
- package/.test/urlencoded.js +0 -54
- package/.vscode/launch.json +0 -35
- package/.vscode/settings.json +0 -5
- package/CHANGELOG.md +0 -10
- package/CODE_OF_CONDUCT.md +0 -76
- package/errata/index.js +0 -1
- package/examples/starter.js +0 -11
- package/index.js +0 -4
- package/jsconfig.json +0 -12
- package/lib/index.js +0 -3
- package/middleware/ContentReaderMiddleware.js +0 -249
- package/middleware/ContentWriterMiddleware.js +0 -161
- package/middleware/SendHeadersMiddleware.js +0 -47
- package/middleware/index.js +0 -11
- package/polyfill/FormData.js +0 -164
- package/rollup.config.js +0 -8
- package/scripts/check-teapot.mjs +0 -40
- package/scripts/test-all-sync.sh +0 -6
- package/scripts/test-all.sh +0 -7
- package/test/fixtures/stream.js +0 -68
- package/test/helpers/HttpListener/construct.js +0 -18
- package/test/helpers/HttpListener/customOptions.js +0 -22
- package/test/helpers/HttpListener/doubleCreate.js +0 -40
- package/test/helpers/HttpListener/events.js +0 -77
- package/test/helpers/HttpListener/http.js +0 -31
- package/test/helpers/HttpListener/http2.js +0 -41
- package/test/helpers/HttpListener/https.js +0 -38
- package/test/helpers/HttpListener/startAll.js +0 -31
- package/test/helpers/HttpListener/stopNotStarted.js +0 -23
- package/test/lib/HttpHandler/class.js +0 -8
- package/test/lib/HttpHandler/handleRequest.js +0 -11
- package/test/lib/HttpHandler/middleware.js +0 -941
- package/test/lib/HttpHandler/parse.js +0 -41
- package/test/lib/HttpRequest/class.js +0 -8
- package/test/lib/HttpRequest/downstream.js +0 -171
- package/test/lib/HttpRequest/properties.js +0 -101
- package/test/lib/HttpRequest/read.js +0 -518
- package/test/lib/HttpResponse/async-iterable-middleware.js +0 -37
- package/test/lib/HttpResponse/async-iterable.js +0 -31
- package/test/lib/HttpResponse/class.js +0 -8
- package/test/lib/HttpResponse/properties.js +0 -59
- package/test/lib/HttpResponse/send.js +0 -275
- package/test/lib/HttpTransaction/class.js +0 -8
- package/test/lib/HttpTransaction/ping.js +0 -50
- package/test/lib/HttpTransaction/push.js +0 -89
- package/test/middleware/SendJsonMiddleware.js +0 -222
- package/test/sanity.js +0 -10
- package/test/templates/error-teapot.js +0 -47
- package/test/templates/starter.js +0 -93
- package/tsconfig.json +0 -30
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** @typedef {import('../data/custom-types.js').HttpTransaction} HttpTransaction */
|
|
2
|
+
/** @typedef {import('../data/custom-types.js').IMiddleware} IMiddleware */
|
|
3
|
+
/** @typedef {import('../data/custom-types.js').MiddlewareFunction} MiddlewareFunction */
|
|
4
|
+
/** @typedef {import('../data/custom-types.js').RequestMethod} RequestMethod */
|
|
5
|
+
/** @typedef {RegExp|string} PathEntry */
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} PathHistoryEntry hello?
|
|
8
|
+
* @prop {string} base
|
|
9
|
+
* @prop {number[]} treeIndex
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {Object} PathState
|
|
13
|
+
* @prop {PathHistoryEntry[]} history
|
|
14
|
+
* @prop {string} currentPath
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {Object} PathMiddlewareOptions
|
|
18
|
+
* @prop {PathEntry|PathEntry[]} [path]
|
|
19
|
+
* @prop {boolean} [absolute=false]
|
|
20
|
+
* Path is not relative to previous PathMiddleware. Defaults to `false`.
|
|
21
|
+
* @prop {boolean} [subPath=false]
|
|
22
|
+
* Path values are subpaths. Default to `false`;
|
|
23
|
+
*/
|
|
24
|
+
export default class PathMiddleware {
|
|
25
|
+
/**
|
|
26
|
+
* @param {PathEntry|PathEntry[]} entry
|
|
27
|
+
*/
|
|
28
|
+
static SUBPATH(entry: PathEntry | PathEntry[]): PathMiddleware;
|
|
29
|
+
/**
|
|
30
|
+
* @param {string} path
|
|
31
|
+
* @param {RegExp | string} input
|
|
32
|
+
* @return {?string}
|
|
33
|
+
*/
|
|
34
|
+
static test(path: string, input: RegExp | string): string | null;
|
|
35
|
+
/**
|
|
36
|
+
* @param {HttpTransaction} transaction
|
|
37
|
+
* @param {string} base new base subpath
|
|
38
|
+
* @param {string} currentPath
|
|
39
|
+
* @return {void}
|
|
40
|
+
*/
|
|
41
|
+
static WritePathState(transaction: HttpTransaction, base: string, currentPath: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* @param {HttpTransaction} transaction
|
|
44
|
+
* @return {string} joined base path
|
|
45
|
+
*/
|
|
46
|
+
static ReadPathState(transaction: HttpTransaction): string;
|
|
47
|
+
/** @param {PathMiddlewareOptions|PathEntry|PathEntry[]} options */
|
|
48
|
+
constructor(options: PathMiddlewareOptions | PathEntry | PathEntry[]);
|
|
49
|
+
path: PathEntry[];
|
|
50
|
+
absolute: boolean;
|
|
51
|
+
subPath: boolean;
|
|
52
|
+
execute(transaction: import("../lib/HttpTransaction.js").default<any>): import("../data/custom-types.js").MiddlewareFunctionResult;
|
|
53
|
+
}
|
|
54
|
+
export type HttpTransaction = import("../data/custom-types.js").HttpTransaction;
|
|
55
|
+
export type IMiddleware = import("../data/custom-types.js").IMiddleware;
|
|
56
|
+
export type MiddlewareFunction = import("../data/custom-types.js").MiddlewareFunction;
|
|
57
|
+
export type RequestMethod = import("../data/custom-types.js").RequestMethod;
|
|
58
|
+
export type PathEntry = RegExp | string;
|
|
59
|
+
/**
|
|
60
|
+
* hello?
|
|
61
|
+
*/
|
|
62
|
+
export type PathHistoryEntry = {
|
|
63
|
+
base: string;
|
|
64
|
+
treeIndex: number[];
|
|
65
|
+
};
|
|
66
|
+
export type PathState = {
|
|
67
|
+
history: PathHistoryEntry[];
|
|
68
|
+
currentPath: string;
|
|
69
|
+
};
|
|
70
|
+
export type PathMiddlewareOptions = {
|
|
71
|
+
path?: PathEntry | PathEntry[];
|
|
72
|
+
/**
|
|
73
|
+
* Path is not relative to previous PathMiddleware. Defaults to `false`.
|
|
74
|
+
*/
|
|
75
|
+
absolute?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Path values are subpaths. Default to `false`;
|
|
78
|
+
*/
|
|
79
|
+
subPath?: boolean;
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=PathMiddleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PathMiddleware.d.ts","sourceRoot":"","sources":["../../middleware/PathMiddleware.js"],"names":[],"mappings":"AAEA,mFAAmF;AACnF,2EAA2E;AAC3E,yFAAyF;AACzF,+EAA+E;AAE/E,yCAAyC;AAEzC;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;;;GAOG;AAEH;IACE;;OAEG;IACH,sBAFW,SAAS,GAAC,SAAS,EAAE,kBAQ/B;IAED;;;;OAIG;IACH,kBAJW,MAAM,SACN,MAAM,GAAG,MAAM,GACb,MAAM,OAAA,CAYlB;IAED;;;;;OAKG;IACH,mCALW,eAAe,QACf,MAAM,eACN,MAAM,GACL,IAAI,CAWf;IAED;;;OAGG;IACH,kCAHW,eAAe,GACd,MAAM,CA4BjB;IAED,mEAAmE;IACnE,qBADY,qBAAqB,GAAC,SAAS,GAAC,SAAS,EAAE,EAetD;IAZG,kBAAmB;IACnB,kBAAqB;IACrB,iBAAoB;;CA4BzB;8BA3Ia,OAAO,yBAAyB,EAAE,eAAe;0BACjD,OAAO,yBAAyB,EAAE,WAAW;iCAC7C,OAAO,yBAAyB,EAAE,kBAAkB;4BACpD,OAAO,yBAAyB,EAAE,aAAa;wBAE/C,MAAM,GAAC,MAAM;;;;;UAIjB,MAAM;eACN,MAAM,EAAE;;;aAKR,gBAAgB,EAAE;iBAClB,MAAM;;;WAKN,SAAS,GAAC,SAAS,EAAE;;;;eACrB,OAAO;;;;cAEP,OAAO"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export default class ReadFormData {
|
|
2
|
+
static Execute(transaction: import("../lib/HttpTransaction.js").default<any>): import("../data/custom-types.js").MiddlewareFunctionResult;
|
|
3
|
+
execute: any;
|
|
4
|
+
}
|
|
5
|
+
export type HttpRequest = import("../lib/HttpRequest.js").default;
|
|
6
|
+
export type MiddlewareFunction = import("../data/custom-types.js").MiddlewareFunction;
|
|
7
|
+
//# sourceMappingURL=ReadFormData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadFormData.d.ts","sourceRoot":"","sources":["../../middleware/ReadFormData.js"],"names":[],"mappings":"AAwFA;;IAEI,aAA8C;CAQjD;0BAlGa,OAAO,uBAAuB,EAAE,OAAO;iCACvC,OAAO,yBAAyB,EAAE,kBAAkB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** @typedef {import('../data/custom-types.js').IMiddleware} IMiddleware */
|
|
2
|
+
/** @typedef {import('../data/custom-types.js').MiddlewareResponseFunction} MiddlewareResponseFunction */
|
|
3
|
+
/** @typedef {import('../data/custom-types.js').MiddlewareFunction} MiddlewareFunction */
|
|
4
|
+
/** @typedef {import('../data/custom-types.js').ResponseFinalizer} ResponseFinalizer */
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} SendJsonMiddlewareOptions
|
|
7
|
+
* @prop {string} [defaultCharset='utf-8']
|
|
8
|
+
* @prop {boolean} [setCharset=true]
|
|
9
|
+
* Automatically applies charset in `Content-Type`
|
|
10
|
+
* @prop {boolean} [setMediaType=true]
|
|
11
|
+
* Automatically applies `application/json` mediatype in `Content-Type`
|
|
12
|
+
*/
|
|
13
|
+
export default class SendJsonMiddleware {
|
|
14
|
+
/** @type {SendJsonMiddleware} */
|
|
15
|
+
static "__#5@#defaultInstance": SendJsonMiddleware;
|
|
16
|
+
/**
|
|
17
|
+
* @param {string} charset
|
|
18
|
+
* @return {BufferEncoding}
|
|
19
|
+
*/
|
|
20
|
+
static charsetAsBufferEncoding(charset: string): BufferEncoding;
|
|
21
|
+
static Execute(transaction: {
|
|
22
|
+
response: import("../lib/HttpResponse.js").default;
|
|
23
|
+
}): import("../data/custom-types.js").MiddlewareFunctionResult;
|
|
24
|
+
/** @param {SendJsonMiddlewareOptions} [options] */
|
|
25
|
+
constructor(options?: SendJsonMiddlewareOptions);
|
|
26
|
+
options: {
|
|
27
|
+
defaultCharset: string;
|
|
28
|
+
setCharset: boolean;
|
|
29
|
+
setMediaType: boolean;
|
|
30
|
+
};
|
|
31
|
+
finalizeResponse(response: import("../data/custom-types.js").HttpResponse): void | null | boolean | Promise<void | null | boolean>;
|
|
32
|
+
execute(transaction: {
|
|
33
|
+
response: import("../lib/HttpResponse.js").default;
|
|
34
|
+
}): import("../data/custom-types.js").MiddlewareFunctionResult;
|
|
35
|
+
}
|
|
36
|
+
export type IMiddleware = import("../data/custom-types.js").IMiddleware;
|
|
37
|
+
export type MiddlewareResponseFunction = import("../data/custom-types.js").MiddlewareResponseFunction;
|
|
38
|
+
export type MiddlewareFunction = import("../data/custom-types.js").MiddlewareFunction;
|
|
39
|
+
export type ResponseFinalizer = import("../data/custom-types.js").ResponseFinalizer;
|
|
40
|
+
export type SendJsonMiddlewareOptions = {
|
|
41
|
+
defaultCharset?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Automatically applies charset in `Content-Type`
|
|
44
|
+
*/
|
|
45
|
+
setCharset?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Automatically applies `application/json` mediatype in `Content-Type`
|
|
48
|
+
*/
|
|
49
|
+
setMediaType?: boolean;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=SendJsonMiddleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SendJsonMiddleware.d.ts","sourceRoot":"","sources":["../../middleware/SendJsonMiddleware.js"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,yGAAyG;AACzG,yFAAyF;AACzF,uFAAuF;AAEvF;;;;;;;GAOG;AAIH;IACE,iCAAiC;IACjC,gCADW,kBAAkB,CACL;IAExB;;;OAGG;IACH,wCAHW,MAAM,GACL,cAAc,CAsBzB;;;;IAcD,mDAAmD;IACnD,sBADY,yBAAyB,EASpC;IAPC;;;;MAIC;;;;;CAkEJ;0BAlIa,OAAO,yBAAyB,EAAE,WAAW;yCAC7C,OAAO,yBAAyB,EAAE,0BAA0B;iCAC5D,OAAO,yBAAyB,EAAE,kBAAkB;gCACpD,OAAO,yBAAyB,EAAE,iBAAiB;;qBAIvD,MAAM;;;;iBACN,OAAO;;;;mBAEP,OAAO"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** @typedef {import('../data/custom-types.js').IMiddleware} IMiddleware */
|
|
2
|
+
/** @typedef {import('../data/custom-types.js').MiddlewareFunction} MiddlewareFunction */
|
|
3
|
+
/** @typedef {import('../data/custom-types.js').ResponseFinalizer} ResponseFinalizer */
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} SendStringMiddlewareOptions
|
|
6
|
+
* @prop {string} [defaultCharset='utf-8']
|
|
7
|
+
* @prop {boolean} [setCharset=true]
|
|
8
|
+
* Automatically applies charset in `Content-Type`
|
|
9
|
+
*/
|
|
10
|
+
export default class SendStringMiddleware {
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} charset
|
|
13
|
+
* @return {BufferEncoding}
|
|
14
|
+
*/
|
|
15
|
+
static charsetAsBufferEncoding(charset: string): BufferEncoding;
|
|
16
|
+
/** @param {SendStringMiddlewareOptions} [options] */
|
|
17
|
+
constructor(options?: SendStringMiddlewareOptions);
|
|
18
|
+
options: {
|
|
19
|
+
defaultCharset: string;
|
|
20
|
+
setCharset: boolean;
|
|
21
|
+
};
|
|
22
|
+
finalizeResponse(response: import("../data/custom-types.js").HttpResponse): void | null | boolean | Promise<void | null | boolean>;
|
|
23
|
+
execute(transaction: import("../lib/HttpTransaction.js").default<any>): import("../data/custom-types.js").MiddlewareFunctionResult;
|
|
24
|
+
}
|
|
25
|
+
export type IMiddleware = import("../data/custom-types.js").IMiddleware;
|
|
26
|
+
export type MiddlewareFunction = import("../data/custom-types.js").MiddlewareFunction;
|
|
27
|
+
export type ResponseFinalizer = import("../data/custom-types.js").ResponseFinalizer;
|
|
28
|
+
export type SendStringMiddlewareOptions = {
|
|
29
|
+
defaultCharset?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Automatically applies charset in `Content-Type`
|
|
32
|
+
*/
|
|
33
|
+
setCharset?: boolean;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=SendStringMiddleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SendStringMiddleware.d.ts","sourceRoot":"","sources":["../../middleware/SendStringMiddleware.js"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,yFAAyF;AACzF,uFAAuF;AAEvF;;;;;GAKG;AAEH;IAWE;;;OAGG;IACH,wCAHW,MAAM,GACL,cAAc,CAsBzB;IAlCD,qDAAqD;IACrD,sBADY,2BAA2B,EAQtC;IANC;;;MAGC;;;CAqEJ;0BAtFa,OAAO,yBAAyB,EAAE,WAAW;iCAC7C,OAAO,yBAAyB,EAAE,kBAAkB;gCACpD,OAAO,yBAAyB,EAAE,iBAAiB;;qBAIvD,MAAM;;;;iBACN,OAAO"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Object} options
|
|
3
|
+
* @param {string} [options.host='0.0.0.0']
|
|
4
|
+
* @param {number} [options.port=8080]
|
|
5
|
+
* @param {import('../data/custom-types.js').Middleware[]} [options.middleware]
|
|
6
|
+
* @param {import('../data/custom-types.js').MiddlewareErrorHandler[]} [options.errorHandlers]
|
|
7
|
+
* @return {Promise<import('../helpers/HttpListener.js').default>}
|
|
8
|
+
*/
|
|
9
|
+
export function start(options: {
|
|
10
|
+
host?: string;
|
|
11
|
+
port?: number;
|
|
12
|
+
middleware?: import("../data/custom-types.js").Middleware[];
|
|
13
|
+
errorHandlers?: import("../data/custom-types.js").MiddlewareErrorHandler[];
|
|
14
|
+
}): Promise<import("../helpers/HttpListener.js").default>;
|
|
15
|
+
//# sourceMappingURL=starter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"starter.d.ts","sourceRoot":"","sources":["../../templates/starter.js"],"names":[],"mappings":"AAWA;;;;;;;GAOG;AACH,+BANG;IAAyB,IAAI,GAArB,MAAM;IACW,IAAI,GAArB,MAAM;IACmD,UAAU,GAAnE,OAAO,yBAAyB,EAAE,UAAU,EAAE;IACuB,aAAa,GAAlF,OAAO,yBAAyB,EAAE,sBAAsB,EAAE;CAClE,GAAS,OAAO,CAAC,OAAO,4BAA4B,EAAE,OAAO,CAAC,CAqChE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template {any} T
|
|
3
|
+
* @class AsyncObject<T>
|
|
4
|
+
*/
|
|
5
|
+
export default class AsyncObject<T extends unknown> {
|
|
6
|
+
/** @param {T} [value] */
|
|
7
|
+
constructor(value?: T);
|
|
8
|
+
value: T;
|
|
9
|
+
ready: boolean;
|
|
10
|
+
busy: boolean;
|
|
11
|
+
/** @type {{resolve:function(T):void, reject:function(Error?):void}[]} */
|
|
12
|
+
pendingPromises: {
|
|
13
|
+
resolve: (arg0: T) => void;
|
|
14
|
+
reject: (arg0: Error | null) => void;
|
|
15
|
+
}[];
|
|
16
|
+
hasValue(): boolean;
|
|
17
|
+
isBusy(): boolean;
|
|
18
|
+
/** @return {Promise<T>} */
|
|
19
|
+
get(): Promise<T>;
|
|
20
|
+
/**
|
|
21
|
+
* @param {T} [value]
|
|
22
|
+
* @return {T}
|
|
23
|
+
*/
|
|
24
|
+
set(value?: T): T;
|
|
25
|
+
/**
|
|
26
|
+
* @param {Error} [error] Error passed to pending promises
|
|
27
|
+
* @return {void}
|
|
28
|
+
*/
|
|
29
|
+
reset(error?: Error): void;
|
|
30
|
+
/**
|
|
31
|
+
* Clear value and mark busy
|
|
32
|
+
* @return {void}
|
|
33
|
+
*/
|
|
34
|
+
prepare(): void;
|
|
35
|
+
/** @return {void} */
|
|
36
|
+
setBusy(): void;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=AsyncObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncObject.d.ts","sourceRoot":"","sources":["../../utils/AsyncObject.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,iCAHmB,CAAC;IAIlB,yBAAyB;IACzB,oBADY,CAAC,EAOZ;IALC,SAAkB;IAClB,eAAkB;IAClB,cAAiB;IACjB,yEAAyE;IACzE,iBADW;QAAC,OAAO,EAAC,CAAS,IAAC,EAAD,CAAC,KAAE,IAAI,CAAC;QAAC,MAAM,EAAC,CAAS,IAAM,EAAN,KAAK,OAAC,KAAE,IAAI,CAAA;KAAC,EAAE,CAC5C;IAG3B,oBAEC;IAED,kBAEC;IAED,2BAA2B;IAC3B,OADa,OAAO,CAAC,CAAC,CAAC,CAQtB;IAED;;;OAGG;IACH,YAHW,CAAC,GACA,CAAC,CAUZ;IAED;;;OAGG;IACH,cAHW,KAAK,GACJ,IAAI,CASf;IAED;;;OAGG;IACH,WAFY,IAAI,CAMf;IAED,qBAAqB;IACrB,WADa,IAAI,CAGhB;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare class CaseInsensitiveObject {
|
|
2
|
+
/** @param {Object} [object] */
|
|
3
|
+
constructor(object?: Object);
|
|
4
|
+
}
|
|
5
|
+
declare namespace CaseInsensitiveObject {
|
|
6
|
+
let defaultProxyHandler: ProxyHandler<Object>;
|
|
7
|
+
}
|
|
8
|
+
export default CaseInsensitiveObject;
|
|
9
|
+
//# sourceMappingURL=CaseInsensitiveObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CaseInsensitiveObject.d.ts","sourceRoot":"","sources":["../../utils/CaseInsensitiveObject.js"],"names":[],"mappings":"AAAA;IACE,+BAA+B;IAC/B,qBADY,MAAM,EAajB;CACF;;6BAEU,YAAY,CAAC,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../utils/function.js"],"names":[],"mappings":"AAAO,6BAAqB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../utils/headers.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,8CAHY,MAAM,OAAA,GACN,OAAO,yBAAyB,EAAE,SAAS,CAsCtD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @typedef {{q:number?} & {[key:string]:string}} ParsedQualityValues */
|
|
2
|
+
/**
|
|
3
|
+
* @param {string} input
|
|
4
|
+
* @return {Map<string, ParsedQualityValues>}
|
|
5
|
+
*/
|
|
6
|
+
export function parseQualityValues(input: string): Map<string, ParsedQualityValues>;
|
|
7
|
+
export type ParsedQualityValues = {
|
|
8
|
+
q: number | null;
|
|
9
|
+
} & {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=qualityValues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qualityValues.d.ts","sourceRoot":"","sources":["../../utils/qualityValues.js"],"names":[],"mappings":"AAAA,yEAAyE;AAEzE;;;GAGG;AACH,0CAHW,MAAM,GACL,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CA2B3C;kCA/Ba;IAAC,CAAC,EAAC,MAAM,OAAC,CAAA;CAAC,GAAG;IAAC,CAAC,GAAG,EAAC,MAAM,GAAE,MAAM,CAAA;CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('node:stream').Writable|import('node:http').ServerResponse} writableLike
|
|
3
|
+
* @return {boolean}
|
|
4
|
+
*/
|
|
5
|
+
export function isWritable(writableLike: import("node:stream").Writable | import("node:http").ServerResponse): boolean;
|
|
6
|
+
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../utils/stream.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,yCAHW,OAAO,aAAa,EAAE,QAAQ,GAAC,OAAO,WAAW,EAAE,cAAc,GAChE,OAAO,CAIlB"}
|
package/utils/headers.js
CHANGED
package/.eslintrc.json
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"es2021": true
|
|
4
|
-
},
|
|
5
|
-
"extends": [
|
|
6
|
-
"airbnb-base",
|
|
7
|
-
"plugin:@typescript-eslint/recommended",
|
|
8
|
-
"plugin:jsdoc/recommended-typescript-flavor-error",
|
|
9
|
-
"plugin:n/recommended",
|
|
10
|
-
"plugin:unicorn/recommended",
|
|
11
|
-
"plugin:import/recommended"
|
|
12
|
-
],
|
|
13
|
-
"overrides": [
|
|
14
|
-
{
|
|
15
|
-
"files": [
|
|
16
|
-
"*.cjs"
|
|
17
|
-
],
|
|
18
|
-
"rules": {
|
|
19
|
-
"@typescript-eslint/no-var-requires": 0,
|
|
20
|
-
"import/no-nodejs-modules": 0
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
"parser": "@typescript-eslint/parser",
|
|
25
|
-
"parserOptions": {
|
|
26
|
-
"ecmaFeatures": {
|
|
27
|
-
"impliedStrict": true
|
|
28
|
-
},
|
|
29
|
-
"ecmaVersion": 2019,
|
|
30
|
-
"project": "./jsconfig.json",
|
|
31
|
-
"sourceType": "module"
|
|
32
|
-
},
|
|
33
|
-
"plugins": [
|
|
34
|
-
"@typescript-eslint",
|
|
35
|
-
"canonical",
|
|
36
|
-
"jsdoc",
|
|
37
|
-
"n",
|
|
38
|
-
"unicorn",
|
|
39
|
-
"import"
|
|
40
|
-
],
|
|
41
|
-
"root": true,
|
|
42
|
-
"rules": {
|
|
43
|
-
"import/extensions": [
|
|
44
|
-
"error",
|
|
45
|
-
"always",
|
|
46
|
-
{
|
|
47
|
-
"js": "always",
|
|
48
|
-
"mjs": "never"
|
|
49
|
-
}
|
|
50
|
-
],
|
|
51
|
-
"import/no-extraneous-dependencies": "off",
|
|
52
|
-
"import/prefer-default-export": "off",
|
|
53
|
-
"jsdoc/no-defaults": "off",
|
|
54
|
-
"jsdoc/require-param-description": "off",
|
|
55
|
-
"jsdoc/require-property-description": "off",
|
|
56
|
-
"jsdoc/require-returns": "off",
|
|
57
|
-
"jsdoc/require-returns-description": "off",
|
|
58
|
-
"no-continue": "off",
|
|
59
|
-
"no-restricted-syntax": "off",
|
|
60
|
-
"no-return-await": "off",
|
|
61
|
-
"unicorn/explicit-length-check": "off",
|
|
62
|
-
"unicorn/filename-case": "off",
|
|
63
|
-
"unicorn/no-null": "off",
|
|
64
|
-
"unicorn/no-useless-switch-case": "off",
|
|
65
|
-
"unicorn/no-useless-undefined": "off",
|
|
66
|
-
"unicorn/prefer-ternary": [
|
|
67
|
-
"error",
|
|
68
|
-
"only-single-line"
|
|
69
|
-
],
|
|
70
|
-
"unicorn/prevent-abbreviations": [
|
|
71
|
-
"error",
|
|
72
|
-
{
|
|
73
|
-
"checkFilenames": false
|
|
74
|
-
}
|
|
75
|
-
],
|
|
76
|
-
"unicorn/switch-case-braces": "off",
|
|
77
|
-
"unicorn/text-encoding-identifier-case": "off"
|
|
78
|
-
},
|
|
79
|
-
"settings": {
|
|
80
|
-
"jsdoc": {
|
|
81
|
-
"preferredTypes": {
|
|
82
|
-
"array": "Array",
|
|
83
|
-
"object": "Object",
|
|
84
|
-
"object.": "Object<>",
|
|
85
|
-
"object<>": "Object<>",
|
|
86
|
-
"symbol": "Symbol"
|
|
87
|
-
},
|
|
88
|
-
"tagNamePreference": {
|
|
89
|
-
"augment": "extends",
|
|
90
|
-
"constant": "const",
|
|
91
|
-
"property": "prop",
|
|
92
|
-
"returns": "return"
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
package/.github/FUNDING.yml
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
<!-- Auto-generated: guidance for AI coding assistants working on this repo -->
|
|
2
|
-
# Copilot / AI assistant instructions for webhoster
|
|
3
|
-
|
|
4
|
-
This file gives focused, actionable guidance to quickly become productive in this repository.
|
|
5
|
-
|
|
6
|
-
Overview
|
|
7
|
-
- **Purpose**: `webhoster` is a stream-first, middleware-driven HTTP/HTTP2 framework for Node.js. Core classes live in `lib/` (notably `lib/HttpHandler.js`, `lib/HttpRequest.js`, `lib/HttpResponse.js`). Middleware implementations live in `middleware/` and are composed into the `HttpHandler` middleware tree.
|
|
8
|
-
- **Module type**: The project is ESM (`"type": "module"` in `package.json`) and targets Node >v16.13.
|
|
9
|
-
|
|
10
|
-
Key patterns and conventions
|
|
11
|
-
- **Middleware tree**: Middleware can be a function, a filter, an Iterable (e.g. `Set`), or a `Map`. Branching is represented by nested arrays/iterables. See examples in `README.md` and `middleware/` files.
|
|
12
|
-
- **Return values**: Middleware return values drive control flow. Use the `HttpHandler` constants or their aliases:
|
|
13
|
-
- `HttpHandler.CONTINUE` (or `true`, `undefined`, `null`) — continue the branch
|
|
14
|
-
- `HttpHandler.BREAK` (or `false`) — break this branch, move to next
|
|
15
|
-
- `HttpHandler.END` (or `0`) — terminate the middleware tree
|
|
16
|
-
- `number` — treated as an HTTP status code and ends
|
|
17
|
-
- **I/O model**: Requests expose `.read()`, `.stream`, and `.body` helpers. Responses expose `.stream`, `.end()`, `.send()`, `.pipeFrom()` and may call `.pushPath()` for HTTP/2 pushes. See `lib/HttpRequest.js` and `lib/HttpResponse.js`.
|
|
18
|
-
- **Locals**: Per-request state belongs on `request.locals` (or `locals`) and is passed through middleware.
|
|
19
|
-
|
|
20
|
-
Developer workflows
|
|
21
|
-
- **Run tests**: `npm test` (uses `c8` + `ava` for coverage). Unit tests live under `test/` (pattern: `test/**/*.js`, excluding `test/fixtures/**`).
|
|
22
|
-
- **Run full/test-all scripts**: `npm run testall` (async) or `npm run testallsync` (sync). These call the scripts in `scripts/`.
|
|
23
|
-
- **Debug tests**: `npm run debug-test` which runs `ava --serial`.
|
|
24
|
-
- **Coverage**: Coverage created by `c8`; `posttestall`/`posttestallsync` call `c8 report`.
|
|
25
|
-
|
|
26
|
-
Code style & types
|
|
27
|
-
- Project uses `eslint` (Airbnb base + plugins) in devDependencies — follow existing style. There are TypeScript type hints (`types/typings.d.ts`) but the codebase is JavaScript ESM.
|
|
28
|
-
|
|
29
|
-
Where to change behavior
|
|
30
|
-
- Add or alter middleware in `middleware/`. Prefer small, single-responsibility modules: decoding, encoding, header transforms, routing filters (see `PathMiddleware.js`, `MethodMiddleware.js`).
|
|
31
|
-
- Core runtime behavior is in `lib/HttpHandler.js`. Changes here affect branching, error handling, and how middleware results are interpreted.
|
|
32
|
-
|
|
33
|
-
Testing & examples
|
|
34
|
-
- Example middleware composition is in `README.md` and `test/index.js` — use those as canonical examples when adding new middleware or behavior.
|
|
35
|
-
- Write tests under `test/` and avoid touching `test/fixtures/` unless updating fixture data. Use `ava` and follow existing test styles.
|
|
36
|
-
\
|
|
37
|
-
Example: minimal middleware
|
|
38
|
-
|
|
39
|
-
```js
|
|
40
|
-
// middleware/ExampleMiddleware.js
|
|
41
|
-
export default class ExampleMiddleware {
|
|
42
|
-
execute(transaction) {
|
|
43
|
-
transaction.locals = transaction.locals || {};
|
|
44
|
-
transaction.locals.example = (transaction.locals.example || 0) + 1;
|
|
45
|
-
return true; // continue processing
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Test example (AVA):
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
import test from 'ava';
|
|
54
|
-
import ExampleMiddleware from '../middleware/ExampleMiddleware.js';
|
|
55
|
-
|
|
56
|
-
test('ExampleMiddleware increments locals', (t) => {
|
|
57
|
-
const m = new ExampleMiddleware();
|
|
58
|
-
const transaction = { locals: {}, state: { treeIndex: [] }, request: {}, response: {} };
|
|
59
|
-
m.execute(transaction);
|
|
60
|
-
t.is(transaction.locals.example, 1);
|
|
61
|
-
});
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
I added `middleware/ExampleMiddleware.js` and `test/example-middleware.js` to the repo as a runnable template. Run `npm test` to verify the example.
|
|
65
|
-
|
|
66
|
-
Integration points & runtime
|
|
67
|
-
- Typical integration: a server registers handlers:
|
|
68
|
-
- `http1Server.addListener('request', HttpHandler.defaultInstance.handleHttp1Request)`
|
|
69
|
-
- `http2Server.addListener('stream', HttpHandler.defaultInstance.handleHttp2Stream)`
|
|
70
|
-
- Middleware may push HTTP/2 resources using `response.pushPath()` — guard with `if (response.canPushPath)`.
|
|
71
|
-
|
|
72
|
-
Practical tips for PRs and edits
|
|
73
|
-
- Keep changes small and focused. Prefer adding middleware modules over modifying `HttpHandler` unless implementing a framework-level feature.
|
|
74
|
-
- Preserve ESM syntax and `export`/`import` styles. Respect the project's `node` engine minimum.
|
|
75
|
-
- Add or update `test/*.js` for any behavioral change; run `npm test` locally to confirm.
|
|
76
|
-
|
|
77
|
-
Files to inspect when in doubt
|
|
78
|
-
- `lib/HttpHandler.js`, `lib/HttpRequest.js`, `lib/HttpResponse.js`
|
|
79
|
-
- `middleware/*` for existing middleware primitives
|
|
80
|
-
- `test/index.js` and `test/**` for test patterns and usage examples
|
|
81
|
-
- `scripts/test-all.sh` and `scripts/test-all-sync.sh` for CI/test orchestration
|
|
82
|
-
|
|
83
|
-
CI / Workflows
|
|
84
|
-
- `/.github/workflows/test-matrix.yml`: the recommended workflow. Runs `npm ci` + `npm run test` across a Node matrix (`16.13`, `16`, `18`, `20`, `22`) using `actions/setup-node`. Prefer editing this file when you want to change supported Node versions or add reporting steps (Codecov/Upload). Each matrix job uses the display name `Test on Node <version>`.
|
|
85
|
-
- `/.github/workflows/test-with-nvm.yml`: optional workflow that installs `nvm` on the runner and executes `scripts/test-all.sh` to mirror local developer behavior. Keep this for parity/debugging only; the matrix job is preferred for CI.
|
|
86
|
-
|
|
87
|
-
README badges
|
|
88
|
-
- `README.md` contains per-node badges that point to the `test-matrix.yml` workflow and the job names. If you rename the workflow or change the job display name, update the badges in `README.md` accordingly. Badges point to the `master` branch by default.
|
|
89
|
-
|
|
90
|
-
Local & debugging notes
|
|
91
|
-
- Run tests locally (fast):
|
|
92
|
-
- `npm ci`
|
|
93
|
-
- `npm test` (runs `c8 ava`)
|
|
94
|
-
- Run the full multi-version script locally (requires `nvm`):
|
|
95
|
-
- `chmod +x scripts/test-all.sh`
|
|
96
|
-
- `./scripts/test-all.sh`
|
|
97
|
-
- The `scripts/test-all.sh` script runs `nvm install`/`nvm use` for multiple Node versions and then executes `npx c8 --clean false -r none ava` for each version in parallel. A recent fix corrected a typo so the Node 22 step now correctly runs `nvm use 22`.
|
|
98
|
-
|
|
99
|
-
If you need more
|
|
100
|
-
- If anything here is unclear or you'd like more examples (specific middleware templates, test scaffolds, or a debugging recipe), ask and I'll add them.
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
name: Publish Package
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
tags:
|
|
6
|
-
- 'v*'
|
|
7
|
-
|
|
8
|
-
permissions:
|
|
9
|
-
id-token: write # Required for OIDC
|
|
10
|
-
contents: read
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
publish:
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v4
|
|
17
|
-
|
|
18
|
-
- uses: actions/setup-node@v4
|
|
19
|
-
with:
|
|
20
|
-
node-version: '20'
|
|
21
|
-
registry-url: 'https://registry.npmjs.org'
|
|
22
|
-
|
|
23
|
-
# Ensure npm 11.5.1 or later is installed
|
|
24
|
-
- name: Update npm
|
|
25
|
-
run: npm install -g npm@latest
|
|
26
|
-
- run: npm ci
|
|
27
|
-
- run: npm run build --if-present
|
|
28
|
-
- run: npm test
|
|
29
|
-
- run: npm publish
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
name: Test matrix
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: ["master"]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: ["master"]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
test:
|
|
11
|
-
name: Test on Node ${{ matrix.node-version }}
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
strategy:
|
|
14
|
-
matrix:
|
|
15
|
-
node-version: ["16.13", "16", "18", "20", "22"]
|
|
16
|
-
steps:
|
|
17
|
-
- name: Checkout
|
|
18
|
-
uses: actions/checkout@v4
|
|
19
|
-
|
|
20
|
-
- name: Setup Node
|
|
21
|
-
uses: actions/setup-node@v4
|
|
22
|
-
with:
|
|
23
|
-
node-version: ${{ matrix.node-version }}
|
|
24
|
-
cache: 'npm'
|
|
25
|
-
|
|
26
|
-
- name: Install dependencies
|
|
27
|
-
run: npm ci
|
|
28
|
-
|
|
29
|
-
- name: Run tests
|
|
30
|
-
run: npm run test
|
|
31
|
-
|
|
32
|
-
- name: Upload coverage artifact
|
|
33
|
-
if: always()
|
|
34
|
-
uses: actions/upload-artifact@v4
|
|
35
|
-
with:
|
|
36
|
-
name: coverage-${{ matrix.node-version }}
|
|
37
|
-
path: coverage
|
package/.test/benchmark.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import HttpListener from '../helpers/HttpListener.js';
|
|
2
|
-
import HttpHandler from '../lib/HttpHandler.js';
|
|
3
|
-
import AutoHeadersMiddleware from '../middleware/AutoHeadersMiddleware.js';
|
|
4
|
-
import SendJsonMiddleware from '../middleware/SendJsonMiddleware.js';
|
|
5
|
-
import ContentLengthMiddleware from '../middleware/ContentLengthMiddleware.js';
|
|
6
|
-
|
|
7
|
-
const { middleware } = HttpHandler.defaultInstance;
|
|
8
|
-
middleware.push(
|
|
9
|
-
// new HeadMethodMiddleware(), // Discard body content
|
|
10
|
-
new SendJsonMiddleware(),
|
|
11
|
-
// new ContentLengthMiddleware({ delayCycle: false }), // Calculate length of anything after
|
|
12
|
-
// new AutoHeadersMiddleware(), // Send headers automatically
|
|
13
|
-
// new HashMiddleware(), // Hash anything after
|
|
14
|
-
// new ContentEncoderMiddleware(), // Compress anything after
|
|
15
|
-
// new ContentWriterMiddleware({ setCharset: true, setJSON: true }),
|
|
16
|
-
// new ContentDecoderMiddleware(),
|
|
17
|
-
// Automatically reads text, JSON, and form-url-encoded from requests
|
|
18
|
-
// new ContentReaderMiddleware({
|
|
19
|
-
// buildString: true,
|
|
20
|
-
// defaultMediaType: 'application/json',
|
|
21
|
-
// parseJSON: true,
|
|
22
|
-
// formURLEncodedFormat: 'object',
|
|
23
|
-
// }),
|
|
24
|
-
{ hello: "world" },
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
const listener = new HttpListener({ insecurePort: 3000 });
|
|
28
|
-
listener.startAll();
|
package/.test/constants.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export const HTTP_PORT = Number.parseInt(process.env.HTTP_PORT || process.env.PORT || '8080', 10);
|
|
2
|
-
export const HTTPS_PORT = Number.parseInt(process.env.HTTPS_PORT || '8443', 10);
|
|
3
|
-
export const HTTP_HOST = process.env.HTTP_HOST || process.env.HOST || '0.0.0.0';
|
|
4
|
-
export const HTTPS_HOST = process.env.HTTPS_HOST || process.env.HOST || '0.0.0.0';
|