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.
- package/data/custom-types.js +14 -14
- package/package.json +12 -1
- package/types/data/CookieObject.d.ts +34 -0
- package/types/data/CookieObject.d.ts.map +1 -0
- package/types/data/custom-types.d.ts +112 -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/.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/data/middleware.d.ts +0 -14
- package/examples/starter.js +0 -11
- package/jsconfig.json +0 -12
- 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 -29
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} HttpHandlerOptions
|
|
3
|
+
* @prop {Middleware[]} [middleware]
|
|
4
|
+
* @prop {MiddlewareErrorHandler[]} [errorHandlers]
|
|
5
|
+
*/
|
|
6
|
+
export default class HttpHandler {
|
|
7
|
+
/** @type {true} */
|
|
8
|
+
static CONTINUE: true;
|
|
9
|
+
/** @type {false} */
|
|
10
|
+
static BREAK: false;
|
|
11
|
+
/** @type {0} */
|
|
12
|
+
static END: 0;
|
|
13
|
+
/** @return {HttpHandler} */
|
|
14
|
+
static get defaultInstance(): HttpHandler;
|
|
15
|
+
/**
|
|
16
|
+
* @param {any} result
|
|
17
|
+
* @return {?MiddlewareFlowInstruction}
|
|
18
|
+
*/
|
|
19
|
+
static ParseResultSync(result: any): MiddlewareFlowInstruction | null;
|
|
20
|
+
/**
|
|
21
|
+
* @param {string} scheme
|
|
22
|
+
* @param {string} authority
|
|
23
|
+
* @param {string} path
|
|
24
|
+
*/
|
|
25
|
+
static parseURL(scheme: string, authority: string, path: string): {
|
|
26
|
+
href: string;
|
|
27
|
+
origin: string;
|
|
28
|
+
protocol: string;
|
|
29
|
+
username: string;
|
|
30
|
+
password: string;
|
|
31
|
+
host: string;
|
|
32
|
+
hostname: string;
|
|
33
|
+
port: string;
|
|
34
|
+
pathname: string;
|
|
35
|
+
search: string;
|
|
36
|
+
hash: string;
|
|
37
|
+
query: string;
|
|
38
|
+
fragment: string;
|
|
39
|
+
url: string;
|
|
40
|
+
};
|
|
41
|
+
/** @param {HttpHandlerOptions} options */
|
|
42
|
+
constructor(options?: HttpHandlerOptions);
|
|
43
|
+
middleware: import("../data/custom-types.js").Middleware[];
|
|
44
|
+
errorHandlers: import("../data/custom-types.js").MiddlewareErrorHandler[];
|
|
45
|
+
/**
|
|
46
|
+
* @param {HttpTransaction} transaction
|
|
47
|
+
* @return {Promise<HttpTransaction>}
|
|
48
|
+
*/
|
|
49
|
+
handleTransaction(transaction: HttpTransaction): Promise<HttpTransaction>;
|
|
50
|
+
/**
|
|
51
|
+
* @param {import('http').IncomingMessage} incomingMessage
|
|
52
|
+
* @param {import('http').ServerResponse} serverResponse
|
|
53
|
+
* @return {Promise<HttpTransaction>}
|
|
54
|
+
*/
|
|
55
|
+
handleHttp1Request(incomingMessage: import("http").IncomingMessage, serverResponse: import("http").ServerResponse): Promise<HttpTransaction>;
|
|
56
|
+
/**
|
|
57
|
+
* @param {import('http2').ServerHttp2Stream} stream
|
|
58
|
+
* @param {import('http2').IncomingHttpHeaders} headers
|
|
59
|
+
* @param {Partial<import('./HttpTransaction.js').HttpTransactionOptions<unknown>>} [transactionOptions]
|
|
60
|
+
* @return {Promise<HttpTransaction>}
|
|
61
|
+
*/
|
|
62
|
+
handleHttp2Stream(stream: import("http2").ServerHttp2Stream, headers: import("http2").IncomingHttpHeaders, transactionOptions?: Partial<import("./HttpTransaction.js").HttpTransactionOptions<unknown>>): Promise<HttpTransaction>;
|
|
63
|
+
/**
|
|
64
|
+
* @param {HttpTransaction} transaction
|
|
65
|
+
* @param {Middleware} middleware
|
|
66
|
+
* @return {Promise<MiddlewareFlowInstruction>}
|
|
67
|
+
*/
|
|
68
|
+
processMiddleware(transaction: HttpTransaction, middleware: Middleware): Promise<MiddlewareFlowInstruction>;
|
|
69
|
+
}
|
|
70
|
+
export type Middleware = import("../data/custom-types.js").Middleware;
|
|
71
|
+
export type MiddlewareErrorHandler = import("../data/custom-types.js").MiddlewareErrorHandler;
|
|
72
|
+
export type MiddlewareFlowInstruction = import("../data/custom-types.js").MiddlewareFlowInstruction;
|
|
73
|
+
export type RequestMethod = import("../data/custom-types.js").RequestMethod;
|
|
74
|
+
export type HttpHandlerOptions = {
|
|
75
|
+
middleware?: Middleware[];
|
|
76
|
+
errorHandlers?: MiddlewareErrorHandler[];
|
|
77
|
+
};
|
|
78
|
+
import HttpTransaction from './HttpTransaction.js';
|
|
79
|
+
//# sourceMappingURL=HttpHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpHandler.d.ts","sourceRoot":"","sources":["../../lib/HttpHandler.js"],"names":[],"mappings":"AAiBA;;;;GAIG;AACH;IACE,mBAAmB;IACnB,iBADW,IAAI,CACQ;IAEvB,oBAAoB;IACpB,cADW,KAAK,CACK;IAErB,gBAAgB;IAChB,YADW,CAAC,CACG;IAEf,4BAA4B;IAC5B,8BADa,WAAW,CAMvB;IAED;;;OAGG;IACH,+BAHW,GAAG,GACD,yBAAyB,OAAA,CAkBrC;IAED;;;;OAIG;IACH,wBAJW,MAAM,aACN,MAAM,QACN,MAAM;;;;;;;;;;;;;;;MA6DhB;IAED,0CAA0C;IAC1C,sBADY,kBAAkB,EAO7B;IALC,2DAA0C;IAC1C,0EAAgD;IA2IlD;;;OAGG;IACH,+BAHW,eAAe,GACd,OAAO,CAAC,eAAe,CAAC,CAwBnC;IAED;;;;OAIG;IACH,oCAJW,OAAO,MAAM,EAAE,eAAe,kBAC9B,OAAO,MAAM,EAAE,cAAc,GAC5B,OAAO,CAAC,eAAe,CAAC,CAyFnC;IAED;;;;;OAKG;IACH,0BALW,OAAO,OAAO,EAAE,iBAAiB,WACjC,OAAO,OAAO,EAAE,mBAAmB,uBACnC,OAAO,CAAC,OAAO,sBAAsB,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC,GACtE,OAAO,CAAC,eAAe,CAAC,CAiKnC;IApaD;;;;OAIG;IACH,+BAJW,eAAe,cACf,UAAU,GACT,OAAO,CAAC,yBAAyB,CAAC,CAgI7C;CAkSF;yBAriBa,OAAO,yBAAyB,EAAE,UAAU;qCAC5C,OAAO,yBAAyB,EAAE,sBAAsB;wCACxD,OAAO,yBAAyB,EAAE,yBAAyB;4BAC3D,OAAO,yBAAyB,EAAE,aAAa;;iBAOnD,UAAU,EAAE;oBACZ,sBAAsB,EAAE;;4BAbN,sBAAsB"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef HttpRequestOptions
|
|
3
|
+
* @prop {IncomingHttpHeaders} [headers]
|
|
4
|
+
* @prop {RequestMethod} method
|
|
5
|
+
* @prop {Readable} stream
|
|
6
|
+
* @prop {string} href URL.href
|
|
7
|
+
* @prop {URL['origin']} origin URL.origin
|
|
8
|
+
* @prop {URL['protocol']} protocol URL.protocol
|
|
9
|
+
* @prop {URL['username']} username URL.username
|
|
10
|
+
* @prop {URL['password']} password URL.password
|
|
11
|
+
* @prop {URL['host']} host URL.host
|
|
12
|
+
* @prop {URL['hostname']} hostname URL.hostname
|
|
13
|
+
* @prop {URL['port']} port URL.port
|
|
14
|
+
* @prop {URL['pathname']} pathname URL.pathname
|
|
15
|
+
* @prop {URL['search']} search URL.search
|
|
16
|
+
* @prop {URL['hash']} hash URL.hash
|
|
17
|
+
* @prop {string} scheme
|
|
18
|
+
* @prop {string} authority
|
|
19
|
+
* @prop {string} path unparsed path
|
|
20
|
+
* @prop {string} url unparsed url
|
|
21
|
+
* @prop {string} query
|
|
22
|
+
* @prop {string} fragment
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* @implements {URL}
|
|
26
|
+
*/
|
|
27
|
+
export default class HttpRequest implements URL {
|
|
28
|
+
/** @param {HttpRequestOptions} options */
|
|
29
|
+
constructor(options: HttpRequestOptions);
|
|
30
|
+
/** @type {number} Minimum initial buffer size when working with chunks. Default 64KB */
|
|
31
|
+
MIN_INITIAL_BUFFER_SIZE: number;
|
|
32
|
+
/** @type {number} Maximium initial buffer size when working with chunks. Default 4MB */
|
|
33
|
+
MAX_INITIAL_BUFFER_SIZE: number;
|
|
34
|
+
/** @type {number} Absolute maximum buffer size to be allocated per request. Default 64MB */
|
|
35
|
+
MAX_BUFFER_SIZE: number;
|
|
36
|
+
/** @type {ContentReaderRegistration[]} */
|
|
37
|
+
contentReaders: ContentReaderRegistration[];
|
|
38
|
+
/** @type {IncomingHttpHeaders} */
|
|
39
|
+
headers: IncomingHttpHeaders;
|
|
40
|
+
method: import("../data/custom-types.js").RequestMethod;
|
|
41
|
+
stream: Readable;
|
|
42
|
+
href: string;
|
|
43
|
+
origin: string;
|
|
44
|
+
protocol: string;
|
|
45
|
+
username: string;
|
|
46
|
+
password: string;
|
|
47
|
+
host: string;
|
|
48
|
+
hostname: string;
|
|
49
|
+
port: string;
|
|
50
|
+
pathname: string;
|
|
51
|
+
search: string;
|
|
52
|
+
hash: string;
|
|
53
|
+
scheme: string;
|
|
54
|
+
authority: string;
|
|
55
|
+
path: string;
|
|
56
|
+
query: string;
|
|
57
|
+
fragment: string;
|
|
58
|
+
url: string;
|
|
59
|
+
/**
|
|
60
|
+
* @param {import('stream').Duplex} downstream
|
|
61
|
+
* @param {Object} [options]
|
|
62
|
+
* @param {boolean} [options.forwardErrors=true] Forward errors back toward source
|
|
63
|
+
* @param {boolean} [options.autoPipe=true]
|
|
64
|
+
* @param {boolean} [options.autoDestroy=true] Ignored if auto-piping
|
|
65
|
+
* @param {boolean} [options.autoPause=false]
|
|
66
|
+
* @return {Readable} previous tailend stream
|
|
67
|
+
*/
|
|
68
|
+
addDownstream(downstream: import("stream").Duplex, options?: {
|
|
69
|
+
forwardErrors?: boolean;
|
|
70
|
+
autoPipe?: boolean;
|
|
71
|
+
autoDestroy?: boolean;
|
|
72
|
+
autoPause?: boolean;
|
|
73
|
+
}): Readable;
|
|
74
|
+
get bodyUsed(): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* @throws {Error<'NOT_SUPPORTED'>}
|
|
77
|
+
* @return {?ReadableStream}
|
|
78
|
+
*/
|
|
79
|
+
get readable(): ReadableStream | null;
|
|
80
|
+
read(): Promise<any>;
|
|
81
|
+
/**
|
|
82
|
+
* @throws {Error<'MAX_BUFFER_SIZE_REACHED'>}
|
|
83
|
+
* @return {Promise<Buffer>}
|
|
84
|
+
*/
|
|
85
|
+
buffer(): Promise<Buffer>;
|
|
86
|
+
/**
|
|
87
|
+
* @return {Promise<ArrayBufferLike>}
|
|
88
|
+
*/
|
|
89
|
+
arrayBuffer(): Promise<ArrayBufferLike>;
|
|
90
|
+
blob(): Promise<Blob | import("buffer").Blob>;
|
|
91
|
+
text(): Promise<string>;
|
|
92
|
+
/** @return {Promise<any>} */
|
|
93
|
+
json(): Promise<any>;
|
|
94
|
+
get mediaType(): import("../data/custom-types.js").MediaType;
|
|
95
|
+
/** @return {null|undefined|string} */
|
|
96
|
+
get charset(): null | undefined | string;
|
|
97
|
+
get bufferEncoding(): BufferEncoding;
|
|
98
|
+
formData(): Promise<void>;
|
|
99
|
+
get searchParams(): URLSearchParams;
|
|
100
|
+
toJSON(): string;
|
|
101
|
+
toString(): string;
|
|
102
|
+
get body(): ReadableStream<any>;
|
|
103
|
+
#private;
|
|
104
|
+
}
|
|
105
|
+
export type RequestMethod = import("../data/custom-types.js").RequestMethod;
|
|
106
|
+
export type IncomingHttpHeaders = import("http").IncomingHttpHeaders;
|
|
107
|
+
export type MediaType = import("../data/custom-types.js").MediaType;
|
|
108
|
+
export type ContentReaderRegistration = Partial<MediaType> & {
|
|
109
|
+
parse: (this: HttpRequest) => any | PromiseLike<any>;
|
|
110
|
+
test?: (this: HttpRequest, mediaType: MediaType) => boolean;
|
|
111
|
+
};
|
|
112
|
+
export type HttpRequestOptions = {
|
|
113
|
+
headers?: IncomingHttpHeaders;
|
|
114
|
+
method: RequestMethod;
|
|
115
|
+
stream: Readable;
|
|
116
|
+
/**
|
|
117
|
+
* URL.href
|
|
118
|
+
*/
|
|
119
|
+
href: string;
|
|
120
|
+
/**
|
|
121
|
+
* URL.origin
|
|
122
|
+
*/
|
|
123
|
+
origin: URL["origin"];
|
|
124
|
+
/**
|
|
125
|
+
* URL.protocol
|
|
126
|
+
*/
|
|
127
|
+
protocol: URL["protocol"];
|
|
128
|
+
/**
|
|
129
|
+
* URL.username
|
|
130
|
+
*/
|
|
131
|
+
username: URL["username"];
|
|
132
|
+
/**
|
|
133
|
+
* URL.password
|
|
134
|
+
*/
|
|
135
|
+
password: URL["password"];
|
|
136
|
+
/**
|
|
137
|
+
* URL.host
|
|
138
|
+
*/
|
|
139
|
+
host: URL["host"];
|
|
140
|
+
/**
|
|
141
|
+
* URL.hostname
|
|
142
|
+
*/
|
|
143
|
+
hostname: URL["hostname"];
|
|
144
|
+
/**
|
|
145
|
+
* URL.port
|
|
146
|
+
*/
|
|
147
|
+
port: URL["port"];
|
|
148
|
+
/**
|
|
149
|
+
* URL.pathname
|
|
150
|
+
*/
|
|
151
|
+
pathname: URL["pathname"];
|
|
152
|
+
/**
|
|
153
|
+
* URL.search
|
|
154
|
+
*/
|
|
155
|
+
search: URL["search"];
|
|
156
|
+
/**
|
|
157
|
+
* URL.hash
|
|
158
|
+
*/
|
|
159
|
+
hash: URL["hash"];
|
|
160
|
+
scheme: string;
|
|
161
|
+
authority: string;
|
|
162
|
+
/**
|
|
163
|
+
* unparsed path
|
|
164
|
+
*/
|
|
165
|
+
path: string;
|
|
166
|
+
/**
|
|
167
|
+
* unparsed url
|
|
168
|
+
*/
|
|
169
|
+
url: string;
|
|
170
|
+
query: string;
|
|
171
|
+
fragment: string;
|
|
172
|
+
};
|
|
173
|
+
import { Readable } from 'node:stream';
|
|
174
|
+
import { URLSearchParams } from 'node:url';
|
|
175
|
+
//# sourceMappingURL=HttpRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpRequest.d.ts","sourceRoot":"","sources":["../../lib/HttpRequest.js"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;GAEG;AACH,4CAFgB,GAAG;IA8BjB,0CAA0C;IAC1C,qBADY,kBAAkB,EAyB7B;IAzCD,wFAAwF;IACxF,yBADW,MAAM,CACmB;IAEpC,wFAAwF;IACxF,yBADW,MAAM,CACyB;IAE1C,4FAA4F;IAC5F,iBADW,MAAM,CACkB;IAEnC,0CAA0C;IAC1C,gBADW,yBAAyB,EAAE,CAKpC;IAIA,kCAAkC;IAClC,SADW,mBAAmB,CACM;IACpC,wDAA4B;IAC5B,iBAA4B;IAE5B,aAAwB;IACxB,eAA4B;IAC5B,iBAAgC;IAChC,iBAAgC;IAChC,iBAAgC;IAChC,aAAwB;IACxB,iBAAgC;IAChC,aAAwB;IACxB,iBAAgC;IAChC,eAA4B;IAC5B,aAAwB;IAExB,eAA4B;IAC5B,kBAAkC;IAClC,aAAwB;IACxB,cAA0B;IAC1B,iBAAgC;IAChC,YAAsB;IAGxB;;;;;;;;OAQG;IACH,0BARW,OAAO,QAAQ,EAAE,MAAM,YAE/B;QAA0B,aAAa,GAA/B,OAAO;QACW,QAAQ,GAA1B,OAAO;QACW,WAAW,GAA7B,OAAO;QACW,SAAS,GAA3B,OAAO;KACf,GAAS,QAAQ,CAwBnB;IAED,wBAAyC;IAEzC;;;OAGG;IACH,gBAFa,cAAc,OAAA,CAiB1B;IAED,qBA+BC;IAED;;;OAGG;IACH,UAFY,OAAO,CAAC,MAAM,CAAC,CAqC1B;IAED;;OAEG;IACH,eAFY,OAAO,CAAC,eAAe,CAAC,CAYnC;IAED,8CA2CC;IAED,wBAsBC;IAED,6BAA6B;IAC7B,QADa,OAAO,CAAC,GAAG,CAAC,CAQxB;IAED,6DAwCC;IAED,sCAAsC;IACtC,eADa,IAAI,GAAC,SAAS,GAAC,MAAM,CAGjC;IAED,qCAqBC;IAGD,0BAEC;IAED,oCAGC;IAED,iBAEC;IAED,mBAEC;IAED,gCAEC;;CACF;4BA3Za,OAAO,yBAAyB,EAAE,aAAa;kCAC/C,OAAO,MAAM,EAAE,mBAAmB;wBAClC,OAAO,yBAAyB,EAAE,SAAS;wCAE3C,OAAO,CAAC,SAAS,CAAC,GAAG;IAAC,KAAK,EAAC,CAAC,IAAI,EAAC,WAAW,KAAG,GAAG,GAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAAC,IAAI,CAAC,EAAC,CAAC,IAAI,EAAC,WAAW,EAAE,SAAS,EAAE,SAAS,KAAG,OAAO,CAAA;CAAC;;cAYlI,mBAAmB;YACnB,aAAa;YACb,QAAQ;;;;UACR,MAAM;;;;YACN,GAAG,CAAC,QAAQ,CAAC;;;;cACb,GAAG,CAAC,UAAU,CAAC;;;;cACf,GAAG,CAAC,UAAU,CAAC;;;;cACf,GAAG,CAAC,UAAU,CAAC;;;;UACf,GAAG,CAAC,MAAM,CAAC;;;;cACX,GAAG,CAAC,UAAU,CAAC;;;;UACf,GAAG,CAAC,MAAM,CAAC;;;;cACX,GAAG,CAAC,UAAU,CAAC;;;;YACf,GAAG,CAAC,QAAQ,CAAC;;;;UACb,GAAG,CAAC,MAAM,CAAC;YACX,MAAM;eACN,MAAM;;;;UACN,MAAM;;;;SACN,MAAM;WACN,MAAM;cACN,MAAM;;yBAtCS,aAAa;gCACN,UAAU"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/** @typedef {import('http').OutgoingHttpHeaders} OutgoingHttpHeaders */
|
|
2
|
+
/** @typedef {import('stream').Stream} Stream */
|
|
3
|
+
/** @typedef {import('../data/custom-types.js').Middleware} Middleware */
|
|
4
|
+
/** @typedef {import('./HttpRequest.js').default} HttpRequest */
|
|
5
|
+
/** @typedef {import('../data/custom-types.js').ResponseFinalizer} ResponseFinalizer */
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} HttpResponseOptions
|
|
8
|
+
* @prop {HttpRequest} [request]
|
|
9
|
+
* @prop {OutgoingHttpHeaders} [headers]
|
|
10
|
+
* @prop {function():boolean} [onHeadersSent]
|
|
11
|
+
* @prop {(flush:boolean, end:boolean) => any} [onSendHeaders]
|
|
12
|
+
* @prop {number} [status]
|
|
13
|
+
* @prop {Writable} stream
|
|
14
|
+
* @prop {Stream[]} [pipes]
|
|
15
|
+
* @prop {ResponseFinalizer[]} [finalizers] inline middleware for message body
|
|
16
|
+
* @prop {any} [body]
|
|
17
|
+
*/
|
|
18
|
+
export default class HttpResponse {
|
|
19
|
+
/** @param {HttpResponseOptions} options */
|
|
20
|
+
constructor(options: HttpResponseOptions);
|
|
21
|
+
request: import("./HttpRequest.js").default;
|
|
22
|
+
/** @type {OutgoingHttpHeaders} */
|
|
23
|
+
headers: OutgoingHttpHeaders;
|
|
24
|
+
isStreaming: boolean;
|
|
25
|
+
stream: import("stream").Writable;
|
|
26
|
+
pipes: import("stream").Stream[];
|
|
27
|
+
/** @type {ResponseFinalizer[]} */
|
|
28
|
+
finalizers: ResponseFinalizer[];
|
|
29
|
+
status: number;
|
|
30
|
+
/** @type {any} */
|
|
31
|
+
body: any;
|
|
32
|
+
set statusCode(number: number);
|
|
33
|
+
get statusCode(): number;
|
|
34
|
+
/**
|
|
35
|
+
* A boolean indicating whether the response was successful (status in the range 200–299) or not.
|
|
36
|
+
* @return {boolean}
|
|
37
|
+
*/
|
|
38
|
+
get ok(): boolean;
|
|
39
|
+
get headersSent(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* @param {boolean} [flush] Flush headers
|
|
42
|
+
* @param {boolean} [end] End stream
|
|
43
|
+
* @return {void}
|
|
44
|
+
*/
|
|
45
|
+
sendHeaders(flush?: boolean, end?: boolean): void;
|
|
46
|
+
/**
|
|
47
|
+
* @param {number} [status]
|
|
48
|
+
* @return {Promise<0>} HttpHandler.END
|
|
49
|
+
*/
|
|
50
|
+
sendStatusOnly(status?: number): Promise<0>;
|
|
51
|
+
/**
|
|
52
|
+
* Send message body to response stream without finalizers
|
|
53
|
+
* @param {any} [body]
|
|
54
|
+
* @return {Promise<0>}
|
|
55
|
+
*/
|
|
56
|
+
sendRaw(body?: any): Promise<0>;
|
|
57
|
+
/** @return {boolean} */
|
|
58
|
+
hasPipeline(): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* @param {import('stream').Transform} stream
|
|
61
|
+
* @return {this}
|
|
62
|
+
*/
|
|
63
|
+
addUpstream(stream: import("stream").Transform): this;
|
|
64
|
+
/**
|
|
65
|
+
* @param {(err: NodeJS.ErrnoException | null) => void} [callback] pipeline completion
|
|
66
|
+
* @return {Writable}
|
|
67
|
+
*/
|
|
68
|
+
getPipeline(callback?: (err: NodeJS.ErrnoException | null) => void): Writable;
|
|
69
|
+
/**
|
|
70
|
+
* Asynchronously sends message body
|
|
71
|
+
* Returns on completions
|
|
72
|
+
* @throws {Error}
|
|
73
|
+
* @param {any} [body]
|
|
74
|
+
* @return {Promise<0>} HttpHandler.END
|
|
75
|
+
*/
|
|
76
|
+
send(body?: any): Promise<0>;
|
|
77
|
+
wasEndCalled(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Synchronously ends stream with message body. Ignores errors
|
|
80
|
+
* @param {any} [body]
|
|
81
|
+
* @return {0} HttpHandler.END
|
|
82
|
+
*/
|
|
83
|
+
end(body?: any): 0;
|
|
84
|
+
/**
|
|
85
|
+
* @param {number} status
|
|
86
|
+
* @return {this}
|
|
87
|
+
*/
|
|
88
|
+
code(status: number): this;
|
|
89
|
+
/**
|
|
90
|
+
* @param {number} status
|
|
91
|
+
* @throws {Error<ERR_HEADER_SENT>}
|
|
92
|
+
* @return {this}
|
|
93
|
+
*/
|
|
94
|
+
setStatus(status: number): this;
|
|
95
|
+
#private;
|
|
96
|
+
}
|
|
97
|
+
export type Writable = import("stream").Writable;
|
|
98
|
+
export type OutgoingHttpHeaders = import("http").OutgoingHttpHeaders;
|
|
99
|
+
export type Stream = import("stream").Stream;
|
|
100
|
+
export type Middleware = import("../data/custom-types.js").Middleware;
|
|
101
|
+
export type HttpRequest = import("./HttpRequest.js").default;
|
|
102
|
+
export type ResponseFinalizer = import("../data/custom-types.js").ResponseFinalizer;
|
|
103
|
+
export type HttpResponseOptions = {
|
|
104
|
+
request?: HttpRequest;
|
|
105
|
+
headers?: OutgoingHttpHeaders;
|
|
106
|
+
onHeadersSent?: () => boolean;
|
|
107
|
+
onSendHeaders?: (flush: boolean, end: boolean) => any;
|
|
108
|
+
status?: number;
|
|
109
|
+
stream: Writable;
|
|
110
|
+
pipes?: Stream[];
|
|
111
|
+
/**
|
|
112
|
+
* inline middleware for message body
|
|
113
|
+
*/
|
|
114
|
+
finalizers?: ResponseFinalizer[];
|
|
115
|
+
body?: any;
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=HttpResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpResponse.d.ts","sourceRoot":"","sources":["../../lib/HttpResponse.js"],"names":[],"mappings":"AAWA,wEAAwE;AACxE,gDAAgD;AAChD,yEAAyE;AACzE,gEAAgE;AAChE,uFAAuF;AAEvF;;;;;;;;;;;GAWG;AAEH;IAmBE,2CAA2C;IAC3C,qBADY,mBAAmB,EAe9B;IAbC,4CAA8B;IAC9B,kCAAkC;IAClC,SADW,mBAAmB,CACM;IACpC,qBAAwB;IACxB,kCAA4B;IAC5B,iCAAgC;IAChC,kCAAkC;IAClC,YADW,iBAAiB,EAAE,CACY;IAC1C,eAA4B;IAC5B,kBAAkB;IAClB,MADW,GAAG,CACU;IAS1B,+BAEC;IAND,yBAEC;IAMD;;;OAGG;IACH,UAFY,OAAO,CAIlB;IAED,2BAIC;IAED;;;;OAIG;IACH,oBAJW,OAAO,QACP,OAAO,GACN,IAAI,CAWf;IAED;;;OAGG;IACH,wBAHW,MAAM,GACL,OAAO,CAAC,CAAC,CAAC,CAUrB;IAED;;;;OAIG;IACH,eAHW,GAAG,GACF,OAAO,CAAC,CAAC,CAAC,CASrB;IAED,wBAAwB;IACxB,eADa,OAAO,CAGnB;IAED;;;OAGG;IACH,oBAHW,OAAO,QAAQ,EAAE,SAAS,GACzB,IAAI,CAKf;IAED;;;OAGG;IACH,uBAHW,CAAC,GAAG,EAAE,MAAM,CAAC,cAAc,GAAG,IAAI,KAAK,IAAI,GAC1C,QAAQ,CAmDnB;IAED;;;;;;OAMG;IACH,YAHW,GAAG,GACF,OAAO,CAAC,CAAC,CAAC,CA6CrB;IAED,wBAEC;IAED;;;;OAIG;IACH,WAHW,GAAG,GACF,CAAC,CAmGZ;IAID;;;OAGG;IACH,aAHW,MAAM,GACL,IAAI,CAKf;IAED;;;;OAIG;IACH,kBAJW,MAAM,GAEL,IAAI,CAMf;;CACF;uBAzXa,OAAO,QAAQ,EAAE,QAAQ;kCAMzB,OAAO,MAAM,EAAE,mBAAmB;qBAClC,OAAO,QAAQ,EAAE,MAAM;yBACvB,OAAO,yBAAyB,EAAE,UAAU;0BAC5C,OAAO,kBAAkB,EAAE,OAAO;gCAClC,OAAO,yBAAyB,EAAE,iBAAiB;;cAIvD,WAAW;cACX,mBAAmB;oBACnB,MAAW,OAAO;oBAClB,CAAC,KAAK,EAAC,OAAO,EAAE,GAAG,EAAC,OAAO,KAAK,GAAG;aACnC,MAAM;YACN,QAAQ;YACR,MAAM,EAAE;;;;iBACR,iBAAiB,EAAE;WACnB,GAAG"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/** @typedef {import('./HttpRequest.js').default} HttpRequest */
|
|
2
|
+
/** @typedef {import('./HttpResponse.js').default} HttpResponse */
|
|
3
|
+
/** @typedef {import('stream').Stream} Stream */
|
|
4
|
+
/** @typedef {import('../data/custom-types.js').MediaType} MediaType */
|
|
5
|
+
/** @typedef {import('../data/custom-types.js').Middleware} Middleware */
|
|
6
|
+
/** @typedef {import('stream').Writable} Writable */
|
|
7
|
+
/** @typedef {Partial<MediaType> & {parse:(this:HttpRequest)=>any|PromiseLike<any>, test?:(this:HttpRequest, mediaType: MediaType)=>boolean}} ContentReaderRegistration */
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Object} PathHistoryEntry
|
|
10
|
+
* @prop {string} base
|
|
11
|
+
* @prop {number[]} treeIndex
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {Object} PathState
|
|
15
|
+
* @prop {PathHistoryEntry[]} history
|
|
16
|
+
* @prop {string} currentPath
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Object} HttpTransactionState
|
|
20
|
+
* @prop {number[]} treeIndex Middleware level
|
|
21
|
+
* @prop {PathState} path
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* @template {Object<string,any>} T
|
|
25
|
+
* @typedef HttpTransactionOptions
|
|
26
|
+
* @prop {string} httpVersion
|
|
27
|
+
* @prop {HttpRequest} [request]
|
|
28
|
+
* @prop {HttpResponse} [response]
|
|
29
|
+
* @prop {import('net').Socket|import('tls').TLSSocket} socket
|
|
30
|
+
* @prop {boolean} [canPing]
|
|
31
|
+
* @prop {(function():Promise<any>)|(function():any)} [onPing]
|
|
32
|
+
* @prop {boolean|function():boolean} [canPushPath]
|
|
33
|
+
* @prop {(path:string) => Promise<any>} [onPushPath]
|
|
34
|
+
* @prop {function():boolean} [onHeadersSent]
|
|
35
|
+
* @prop {(flush:boolean, end:boolean) => boolean} [onSendHeaders]
|
|
36
|
+
* @prop {T} [locals]
|
|
37
|
+
* @prop {HttpTransactionState} [state]
|
|
38
|
+
* @prop {Error} [error]
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* @template {Object<string,any>} [T=any]
|
|
42
|
+
*/
|
|
43
|
+
export default class HttpTransaction<T extends {
|
|
44
|
+
[x: string]: any;
|
|
45
|
+
} = any> {
|
|
46
|
+
/** @param {HttpTransactionOptions<T>} options */
|
|
47
|
+
constructor(options: HttpTransactionOptions<T>);
|
|
48
|
+
request: import("./HttpRequest.js").default;
|
|
49
|
+
response: import("./HttpResponse.js").default;
|
|
50
|
+
/** @type {T} */
|
|
51
|
+
locals: T;
|
|
52
|
+
state: HttpTransactionState;
|
|
53
|
+
socket: import("net").Socket | import("tls").TLSSocket;
|
|
54
|
+
httpVersion: string;
|
|
55
|
+
error: Error;
|
|
56
|
+
setErrorHandlerState(): void;
|
|
57
|
+
isErrorHandlerState(): boolean;
|
|
58
|
+
get canPing(): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* @return {Promise<any>}
|
|
61
|
+
*/
|
|
62
|
+
ping(): Promise<any>;
|
|
63
|
+
get pushedPaths(): string[];
|
|
64
|
+
get canPushPath(): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* @param {string} [path]
|
|
67
|
+
* @return {Promise<any>}
|
|
68
|
+
*/
|
|
69
|
+
pushPath(path?: string): Promise<any>;
|
|
70
|
+
#private;
|
|
71
|
+
}
|
|
72
|
+
export type HttpRequest = import("./HttpRequest.js").default;
|
|
73
|
+
export type HttpResponse = import("./HttpResponse.js").default;
|
|
74
|
+
export type Stream = import("stream").Stream;
|
|
75
|
+
export type MediaType = import("../data/custom-types.js").MediaType;
|
|
76
|
+
export type Middleware = import("../data/custom-types.js").Middleware;
|
|
77
|
+
export type Writable = import("stream").Writable;
|
|
78
|
+
export type ContentReaderRegistration = Partial<MediaType> & {
|
|
79
|
+
parse: (this: HttpRequest) => any | PromiseLike<any>;
|
|
80
|
+
test?: (this: HttpRequest, mediaType: MediaType) => boolean;
|
|
81
|
+
};
|
|
82
|
+
export type PathHistoryEntry = {
|
|
83
|
+
base: string;
|
|
84
|
+
treeIndex: number[];
|
|
85
|
+
};
|
|
86
|
+
export type PathState = {
|
|
87
|
+
history: PathHistoryEntry[];
|
|
88
|
+
currentPath: string;
|
|
89
|
+
};
|
|
90
|
+
export type HttpTransactionState = {
|
|
91
|
+
/**
|
|
92
|
+
* Middleware level
|
|
93
|
+
*/
|
|
94
|
+
treeIndex: number[];
|
|
95
|
+
path: PathState;
|
|
96
|
+
};
|
|
97
|
+
export type HttpTransactionOptions<T extends {
|
|
98
|
+
[x: string]: any;
|
|
99
|
+
}> = {
|
|
100
|
+
httpVersion: string;
|
|
101
|
+
request?: HttpRequest;
|
|
102
|
+
response?: HttpResponse;
|
|
103
|
+
socket: import("net").Socket | import("tls").TLSSocket;
|
|
104
|
+
canPing?: boolean;
|
|
105
|
+
onPing?: (() => Promise<any>) | (() => any);
|
|
106
|
+
canPushPath?: boolean | (() => boolean);
|
|
107
|
+
onPushPath?: (path: string) => Promise<any>;
|
|
108
|
+
onHeadersSent?: () => boolean;
|
|
109
|
+
onSendHeaders?: (flush: boolean, end: boolean) => boolean;
|
|
110
|
+
locals?: T;
|
|
111
|
+
state?: HttpTransactionState;
|
|
112
|
+
error?: Error;
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=HttpTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpTransaction.d.ts","sourceRoot":"","sources":["../../lib/HttpTransaction.js"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,kEAAkE;AAClE,gDAAgD;AAEhD,uEAAuE;AACvE,yEAAyE;AACzE,oDAAoD;AAEpD,0KAA0K;AAE1K;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH;;GAEG;AACH,qCAFmC,CAAC,SAAvB;QAAQ,MAAM,GAAC,GAAG;CAAE;IAoB/B,iDAAiD;IACjD,qBADY,sBAAsB,CAAC,CAAC,CAAC,EAsBpC;IApBC,4CAA8B;IAC9B,8CAAgC;IAEhC,gBAAgB;IAChB,QADW,CAAC,CACyC;IACrD,4BAGC;IAED,uDAA4B;IAC5B,oBAAsC;IAQtC,aAA0B;IAG5B,6BAEC;IAED,+BAEC;IAED,uBAIC;IAED;;OAEG;IACH,QAFY,OAAO,CAAC,GAAG,CAAC,CAUvB;IAED,4BAEC;IAED,2BAIC;IAED;;;OAGG;IACH,gBAHW,MAAM,GACL,OAAO,CAAC,GAAG,CAAC,CAcvB;;CACF;0BAjJa,OAAO,kBAAkB,EAAE,OAAO;2BAClC,OAAO,mBAAmB,EAAE,OAAO;qBACnC,OAAO,QAAQ,EAAE,MAAM;wBAEvB,OAAO,yBAAyB,EAAE,SAAS;yBAC3C,OAAO,yBAAyB,EAAE,UAAU;uBAC5C,OAAO,QAAQ,EAAE,QAAQ;wCAEzB,OAAO,CAAC,SAAS,CAAC,GAAG;IAAC,KAAK,EAAC,CAAC,IAAI,EAAC,WAAW,KAAG,GAAG,GAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAAC,IAAI,CAAC,EAAC,CAAC,IAAI,EAAC,WAAW,EAAE,SAAS,EAAE,SAAS,KAAG,OAAO,CAAA;CAAC;;UAIlI,MAAM;eACN,MAAM,EAAE;;;aAKR,gBAAgB,EAAE;iBAClB,MAAM;;;;;;eAKN,MAAM,EAAE;UACR,SAAS;;mCAIe,CAAC,SAAtB;QAAQ,MAAM,GAAC,GAAG;CAAE;iBAEvB,MAAM;cACN,WAAW;eACX,YAAY;YACZ,OAAO,KAAK,EAAE,MAAM,GAAC,OAAO,KAAK,EAAE,SAAS;cAC5C,OAAO;aACP,CAAC,MAAW,OAAO,CAAC,GAAG,CAAC,CAAC,GAAC,CAAC,MAAW,GAAG,CAAC;kBAC1C,OAAO,IAAC,MAAW,OAAO,CAAA;iBAC1B,CAAC,IAAI,EAAC,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC;oBAC7B,MAAW,OAAO;oBAClB,CAAC,KAAK,EAAC,OAAO,EAAE,GAAG,EAAC,OAAO,KAAK,OAAO;aACvC,CAAC;YACD,oBAAoB;YACpB,KAAK"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} AutoHeadersMiddlewareOptions
|
|
3
|
+
* @prop {boolean} [setStatus=true]
|
|
4
|
+
* Automatically set `200` or `204` status if not set
|
|
5
|
+
*/
|
|
6
|
+
export default class AutoHeadersMiddleware {
|
|
7
|
+
/** @param {AutoHeadersMiddlewareOptions} options */
|
|
8
|
+
constructor(options?: AutoHeadersMiddlewareOptions);
|
|
9
|
+
setStatus: boolean;
|
|
10
|
+
finalizeResponse(response: import("../data/custom-types.js").HttpResponse): void | null | boolean | Promise<void | null | boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* @param {HttpResponse} response
|
|
13
|
+
* @return {void}
|
|
14
|
+
*/
|
|
15
|
+
addTransformStream(response: HttpResponse): void;
|
|
16
|
+
execute(transaction: import("../lib/HttpTransaction.js").default<any>): import("../data/custom-types.js").MiddlewareFunctionResult;
|
|
17
|
+
}
|
|
18
|
+
export type HttpResponse = import("../lib/HttpResponse.js").default;
|
|
19
|
+
export type ResponseFinalizer = import("../data/custom-types.js").ResponseFinalizer;
|
|
20
|
+
export type MiddlewareFunction = import("../data/custom-types.js").MiddlewareFunction;
|
|
21
|
+
export type AutoHeadersMiddlewareOptions = {
|
|
22
|
+
/**
|
|
23
|
+
* Automatically set `200` or `204` status if not set
|
|
24
|
+
*/
|
|
25
|
+
setStatus?: boolean;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=AutoHeadersMiddleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoHeadersMiddleware.d.ts","sourceRoot":"","sources":["../../middleware/AutoHeadersMiddleware.js"],"names":[],"mappings":"AAMA;;;;GAIG;AAEH;IACE,oDAAoD;IACpD,sBADY,4BAA4B,EAIvC;IAFC,mBAA4C;;IAI9C;;;OAGG;IACH,6BAHW,YAAY,GACX,IAAI,CA+Bf;;CAoBF;2BAxEa,OAAO,wBAAwB,EAAE,OAAO;gCACxC,OAAO,yBAAyB,EAAE,iBAAiB;iCACnD,OAAO,yBAAyB,EAAE,kBAAkB;;;;;gBAMxD,OAAO"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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').RequestMethod} RequestMethod */
|
|
4
|
+
/**
|
|
5
|
+
* @typedef CORSMiddlewareOptions
|
|
6
|
+
* @prop {(string|RegExp)[]} [allowOrigin]
|
|
7
|
+
* Indicates whether the response can be shared, via returning the literal
|
|
8
|
+
* value of the `Origin` request header (which can be `null`) or `*` in a response.
|
|
9
|
+
* @prop {boolean} [allowCredentials]
|
|
10
|
+
* Indicates whether the response can be shared when request’s credentials mode is "include".
|
|
11
|
+
* @prop {RequestMethod[]} [allowMethods]
|
|
12
|
+
* Indicates which methods are supported by the response’s URL for the purposes of the CORS protocol.
|
|
13
|
+
* @prop {string[]} [allowHeaders]
|
|
14
|
+
* Indicates which headers are supported by the response’s URL for the purposes of the CORS protocol.
|
|
15
|
+
* @prop {number} [maxAge=5]
|
|
16
|
+
* Indicates the number of seconds (5 by default) the information provided by the
|
|
17
|
+
* `Access-Control-Allow-Methods` and `Access-Control-Allow-Headers` headers can be cached.
|
|
18
|
+
* @prop {string[]} [exposeHeaders]
|
|
19
|
+
* Indicates which headers can be exposed as part of the response by listing their names.
|
|
20
|
+
*/
|
|
21
|
+
export default class CORSMiddleware {
|
|
22
|
+
static OK_BUFFER: Buffer<ArrayBuffer>;
|
|
23
|
+
static ACCESS_CONTROL_ALLOW_HEADERS_ALL: string;
|
|
24
|
+
/** @param {CORSMiddlewareOptions} [options] */
|
|
25
|
+
constructor(options?: CORSMiddlewareOptions);
|
|
26
|
+
allowOrigin: (string | RegExp)[];
|
|
27
|
+
allowCredentials: boolean;
|
|
28
|
+
allowMethods: import("../data/custom-types.js").RequestMethod[];
|
|
29
|
+
allowHeaders: string[];
|
|
30
|
+
maxAge: number;
|
|
31
|
+
exposeHeaders: string[];
|
|
32
|
+
execute(transaction: import("../lib/HttpTransaction.js").default<any>): import("../data/custom-types.js").MiddlewareFunctionResult;
|
|
33
|
+
}
|
|
34
|
+
export type IMiddleware = import("../data/custom-types.js").IMiddleware;
|
|
35
|
+
export type MiddlewareFunction = import("../data/custom-types.js").MiddlewareFunction;
|
|
36
|
+
export type RequestMethod = import("../data/custom-types.js").RequestMethod;
|
|
37
|
+
export type CORSMiddlewareOptions = {
|
|
38
|
+
/**
|
|
39
|
+
* Indicates whether the response can be shared, via returning the literal
|
|
40
|
+
* value of the `Origin` request header (which can be `null`) or `*` in a response.
|
|
41
|
+
*/
|
|
42
|
+
allowOrigin?: (string | RegExp)[];
|
|
43
|
+
/**
|
|
44
|
+
* Indicates whether the response can be shared when request’s credentials mode is "include".
|
|
45
|
+
*/
|
|
46
|
+
allowCredentials?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Indicates which methods are supported by the response’s URL for the purposes of the CORS protocol.
|
|
49
|
+
*/
|
|
50
|
+
allowMethods?: RequestMethod[];
|
|
51
|
+
/**
|
|
52
|
+
* Indicates which headers are supported by the response’s URL for the purposes of the CORS protocol.
|
|
53
|
+
*/
|
|
54
|
+
allowHeaders?: string[];
|
|
55
|
+
/**
|
|
56
|
+
* Indicates the number of seconds (5 by default) the information provided by the
|
|
57
|
+
* `Access-Control-Allow-Methods` and `Access-Control-Allow-Headers` headers can be cached.
|
|
58
|
+
*/
|
|
59
|
+
maxAge?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Indicates which headers can be exposed as part of the response by listing their names.
|
|
62
|
+
*/
|
|
63
|
+
exposeHeaders?: string[];
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=CORSMiddleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CORSMiddleware.d.ts","sourceRoot":"","sources":["../../middleware/CORSMiddleware.js"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,yFAAyF;AACzF,+EAA+E;AAE/E;;;;;;;;;;;;;;;;GAgBG;AAEH;IAWE,sCAA8C;IAE9C,gDAEY;IAdZ,+CAA+C;IAC/C,sBADY,qBAAqB,EAQhC;IANC,iCAAsC;IACtC,0BAAyD;IACzD,gEAAwC;IACxC,uBAAwC;IACxC,eAAiC;IACjC,wBAA0C;;CAkE7C;0BAhGa,OAAO,yBAAyB,EAAE,WAAW;iCAC7C,OAAO,yBAAyB,EAAE,kBAAkB;4BACpD,OAAO,yBAAyB,EAAE,aAAa;;;;;;kBAInD,CAAC,MAAM,GAAC,MAAM,CAAC,EAAE;;;;uBAGjB,OAAO;;;;mBAEP,aAAa,EAAE;;;;mBAEf,MAAM,EAAE;;;;;aAER,MAAM;;;;oBAGN,MAAM,EAAE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @typedef {import('../data/custom-types.js').IMiddleware} IMiddleware */
|
|
2
|
+
/** @typedef {import('../data/custom-types.js').MiddlewareFunction} MiddlewareFunction */
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {Object} CaseInsensitiveHeadersMiddlewareOptions
|
|
5
|
+
* @prop {boolean} [request=false] Mutate request headers to be case-insensitive
|
|
6
|
+
* @prop {boolean} [response=false] Mutate response headers to be case-insensistive
|
|
7
|
+
*/
|
|
8
|
+
export default class CaseInsensitiveHeadersMiddleware {
|
|
9
|
+
/** @param {CaseInsensitiveHeadersMiddlewareOptions} options */
|
|
10
|
+
constructor(options: CaseInsensitiveHeadersMiddlewareOptions);
|
|
11
|
+
request: boolean;
|
|
12
|
+
response: boolean;
|
|
13
|
+
execute(transaction: import("../lib/HttpTransaction.js").default<any>): import("../data/custom-types.js").MiddlewareFunctionResult;
|
|
14
|
+
}
|
|
15
|
+
export type IMiddleware = import("../data/custom-types.js").IMiddleware;
|
|
16
|
+
export type MiddlewareFunction = import("../data/custom-types.js").MiddlewareFunction;
|
|
17
|
+
export type CaseInsensitiveHeadersMiddlewareOptions = {
|
|
18
|
+
/**
|
|
19
|
+
* Mutate request headers to be case-insensitive
|
|
20
|
+
*/
|
|
21
|
+
request?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Mutate response headers to be case-insensistive
|
|
24
|
+
*/
|
|
25
|
+
response?: boolean;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=CaseInsensitiveHeadersMiddleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CaseInsensitiveHeadersMiddleware.d.ts","sourceRoot":"","sources":["../../middleware/CaseInsensitiveHeadersMiddleware.js"],"names":[],"mappings":"AAEA,2EAA2E;AAC3E,yFAAyF;AAEzF;;;;GAIG;AAEH;IACE,+DAA+D;IAC/D,qBADY,uCAAuC,EAIlD;IAFC,iBAAuC;IACvC,kBAAyC;;CAc5C;0BA3Ba,OAAO,yBAAyB,EAAE,WAAW;iCAC7C,OAAO,yBAAyB,EAAE,kBAAkB;;;;;cAIxD,OAAO;;;;eACP,OAAO"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements `Accept-Encoding`
|
|
3
|
+
* https://tools.ietf.org/html/rfc7231#section-5.3.4
|
|
4
|
+
*/
|
|
5
|
+
export default class ContentDecoderMiddleware {
|
|
6
|
+
/** @param {ContentDecoderMiddlewareOptions} [options] */
|
|
7
|
+
constructor(options?: ContentDecoderMiddlewareOptions);
|
|
8
|
+
chunkSize: number;
|
|
9
|
+
respondNotAcceptable: boolean;
|
|
10
|
+
execute(transaction: import("../lib/HttpTransaction.js").default<any>): import("../data/custom-types.js").MiddlewareFunctionResult;
|
|
11
|
+
}
|
|
12
|
+
export type MiddlewareFunction = import("../data/custom-types.js").MiddlewareFunction;
|
|
13
|
+
export type ContentDecoderMiddlewareOptions = {
|
|
14
|
+
chunkSize?: number;
|
|
15
|
+
respondNotAcceptable?: boolean;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=ContentDecoderMiddleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentDecoderMiddleware.d.ts","sourceRoot":"","sources":["../../middleware/ContentDecoderMiddleware.js"],"names":[],"mappings":"AAgBA;;;GAGG;AACH;IACE,yDAAyD;IACzD,sBADY,+BAA+B,EAI1C;IAFC,kBAAkC;IAClC,8BAAiE;;CAoHpE;iCAtIa,OAAO,yBAAyB,EAAE,kBAAkB;;gBAIxD,MAAM;2BACN,OAAO"}
|