@wooksjs/event-http 0.4.26 → 0.4.28
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 +8 -8
- package/dist/index.cjs +356 -365
- package/dist/index.d.ts +132 -136
- package/dist/index.mjs +356 -365
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,92 +1,13 @@
|
|
|
1
|
-
import * as http from 'http';
|
|
2
|
-
import http__default, { IncomingHttpHeaders, IncomingMessage, ServerResponse, Server } from 'http';
|
|
3
1
|
import * as _wooksjs_event_core from '@wooksjs/event-core';
|
|
4
2
|
import { TEventOptions, TEmpty } from '@wooksjs/event-core';
|
|
3
|
+
import * as http from 'http';
|
|
4
|
+
import { IncomingMessage, ServerResponse, IncomingHttpHeaders, Server } from 'http';
|
|
5
5
|
import { URLSearchParams } from 'url';
|
|
6
6
|
import { TConsoleBase } from '@prostojs/logger';
|
|
7
7
|
import * as _prostojs_router from '@prostojs/router';
|
|
8
|
+
import { ListenOptions } from 'net';
|
|
8
9
|
import { TWooksHandler, TWooksOptions, WooksAdapterBase, Wooks } from 'wooks';
|
|
9
10
|
|
|
10
|
-
declare function useHeaders(): IncomingHttpHeaders;
|
|
11
|
-
declare function useSetHeaders(): {
|
|
12
|
-
setHeader: (name: string, value: string | number) => void;
|
|
13
|
-
getHeader: <K2 extends string | number>(key2: K2) => {
|
|
14
|
-
[name: string]: string | string[];
|
|
15
|
-
}[K2];
|
|
16
|
-
removeHeader: <K2_1 extends string | number>(key2: K2_1) => void;
|
|
17
|
-
setContentType: (value: string) => void;
|
|
18
|
-
headers: () => {
|
|
19
|
-
[name: string]: string | string[];
|
|
20
|
-
};
|
|
21
|
-
enableCors: (origin?: string) => void;
|
|
22
|
-
};
|
|
23
|
-
declare function useSetHeader(name: string): {
|
|
24
|
-
value: string | string[];
|
|
25
|
-
isDefined: boolean;
|
|
26
|
-
};
|
|
27
|
-
type THeaderHook = ReturnType<typeof useSetHeader>;
|
|
28
|
-
|
|
29
|
-
declare function useAccept(): {
|
|
30
|
-
accept: string | undefined;
|
|
31
|
-
accepts: (mime: string) => unknown;
|
|
32
|
-
acceptsJson: () => unknown;
|
|
33
|
-
acceptsXml: () => unknown;
|
|
34
|
-
acceptsText: () => unknown;
|
|
35
|
-
acceptsHtml: () => unknown;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
declare function useAuthorization(): {
|
|
39
|
-
authorization: string | undefined;
|
|
40
|
-
authType: () => string | null;
|
|
41
|
-
authRawCredentials: () => string | null;
|
|
42
|
-
isBasic: () => boolean;
|
|
43
|
-
isBearer: () => boolean;
|
|
44
|
-
basicCredentials: () => {
|
|
45
|
-
username: string;
|
|
46
|
-
password: string;
|
|
47
|
-
} | null;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
type TTimeUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w' | 'M' | 'Y';
|
|
51
|
-
type TTimeSingleString = `${number}${TTimeUnit}`;
|
|
52
|
-
type TTimeMultiString = `${TTimeSingleString}${TTimeSingleString | ''}${TTimeSingleString | ''}${TTimeSingleString | ''}`;
|
|
53
|
-
|
|
54
|
-
type TCacheControl = {
|
|
55
|
-
mustRevalidate?: boolean;
|
|
56
|
-
noCache?: boolean | string;
|
|
57
|
-
noStore?: boolean;
|
|
58
|
-
noTransform?: boolean;
|
|
59
|
-
public?: boolean;
|
|
60
|
-
private?: boolean | string;
|
|
61
|
-
proxyRevalidate?: boolean;
|
|
62
|
-
maxAge?: number | TTimeMultiString;
|
|
63
|
-
sMaxage?: number | TTimeMultiString;
|
|
64
|
-
};
|
|
65
|
-
declare function renderCacheControl(data: TCacheControl): string;
|
|
66
|
-
|
|
67
|
-
declare function useSetCacheControl(): {
|
|
68
|
-
setExpires: (value: Date | string | number) => void;
|
|
69
|
-
setAge: (value: number | TTimeMultiString) => void;
|
|
70
|
-
setPragmaNoCache: (value?: boolean) => void;
|
|
71
|
-
setCacheControl: (data: TCacheControl) => void;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
declare function useRequest(): {
|
|
75
|
-
rawRequest: http.IncomingMessage;
|
|
76
|
-
url: string | undefined;
|
|
77
|
-
method: string | undefined;
|
|
78
|
-
headers: http.IncomingHttpHeaders;
|
|
79
|
-
rawBody: () => Promise<Buffer>;
|
|
80
|
-
reqId: () => string;
|
|
81
|
-
getIp: (options?: {
|
|
82
|
-
trustProxy: boolean;
|
|
83
|
-
}) => string;
|
|
84
|
-
getIpList: () => {
|
|
85
|
-
remoteIp: string;
|
|
86
|
-
forwarded: string[];
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
|
|
90
11
|
declare const httpStatusCodes: {
|
|
91
12
|
100: string;
|
|
92
13
|
101: string;
|
|
@@ -221,19 +142,9 @@ type THttpBadRequestCodes = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408
|
|
|
221
142
|
type THttpServerErrorCodes = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
|
|
222
143
|
type THttpErrorCodes = THttpBadRequestCodes | THttpServerErrorCodes;
|
|
223
144
|
|
|
224
|
-
type
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
declare function useResponse(): {
|
|
228
|
-
rawResponse: (options?: TUseResponseOptions) => http.ServerResponse<http.IncomingMessage>;
|
|
229
|
-
hasResponded: () => boolean;
|
|
230
|
-
status: ((code?: EHttpStatusCode) => EHttpStatusCode) & _wooksjs_event_core.THook<EHttpStatusCode, "value">;
|
|
231
|
-
};
|
|
232
|
-
declare function useStatus(): {
|
|
233
|
-
value: EHttpStatusCode;
|
|
234
|
-
isDefined: boolean;
|
|
235
|
-
};
|
|
236
|
-
type TStatusHook = ReturnType<typeof useStatus>;
|
|
145
|
+
type TTimeUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w' | 'M' | 'Y';
|
|
146
|
+
type TTimeSingleString = `${number}${TTimeUnit}`;
|
|
147
|
+
type TTimeMultiString = `${TTimeSingleString}${TTimeSingleString | ''}${TTimeSingleString | ''}${TTimeSingleString | ''}`;
|
|
237
148
|
|
|
238
149
|
declare class WooksURLSearchParams extends URLSearchParams {
|
|
239
150
|
toJson<T = unknown>(): T;
|
|
@@ -248,19 +159,11 @@ interface THttpEvent {
|
|
|
248
159
|
}
|
|
249
160
|
interface THttpContextStore {
|
|
250
161
|
searchParams?: TSearchParamsCache;
|
|
251
|
-
cookies?:
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
setCookies?: {
|
|
255
|
-
[name: string]: TSetCookieData;
|
|
256
|
-
};
|
|
257
|
-
accept?: {
|
|
258
|
-
[name: string]: boolean;
|
|
259
|
-
};
|
|
162
|
+
cookies?: Record<string, string | null>;
|
|
163
|
+
setCookies?: Record<string, TSetCookieData>;
|
|
164
|
+
accept?: Record<string, boolean>;
|
|
260
165
|
authorization?: TAuthCache;
|
|
261
|
-
setHeader?:
|
|
262
|
-
[name: string]: string | string[];
|
|
263
|
-
};
|
|
166
|
+
setHeader?: Record<string, string | string[]>;
|
|
264
167
|
request?: TRequestCache;
|
|
265
168
|
response?: {
|
|
266
169
|
responded: boolean;
|
|
@@ -269,10 +172,10 @@ interface THttpContextStore {
|
|
|
269
172
|
code: EHttpStatusCode;
|
|
270
173
|
};
|
|
271
174
|
}
|
|
272
|
-
|
|
175
|
+
interface TSetCookieData {
|
|
273
176
|
value: string;
|
|
274
177
|
attrs: TCookieAttributesInput;
|
|
275
|
-
}
|
|
178
|
+
}
|
|
276
179
|
type TCookieAttributesInput = Partial<TCookieAttributes>;
|
|
277
180
|
interface TCookieAttributes {
|
|
278
181
|
expires: Date | string | number;
|
|
@@ -283,15 +186,15 @@ interface TCookieAttributes {
|
|
|
283
186
|
httpOnly: boolean;
|
|
284
187
|
sameSite: boolean | 'Lax' | 'None' | 'Strict';
|
|
285
188
|
}
|
|
286
|
-
|
|
189
|
+
interface TAuthCache {
|
|
287
190
|
type: string | null;
|
|
288
191
|
credentials: string | null;
|
|
289
192
|
basicCredentials: {
|
|
290
193
|
username: string;
|
|
291
194
|
password: string;
|
|
292
195
|
} | null;
|
|
293
|
-
}
|
|
294
|
-
|
|
196
|
+
}
|
|
197
|
+
interface TRequestCache {
|
|
295
198
|
rawBody: Promise<Buffer>;
|
|
296
199
|
parsed: unknown;
|
|
297
200
|
forwardedIp?: string;
|
|
@@ -300,11 +203,11 @@ type TRequestCache = {
|
|
|
300
203
|
remoteIp: string;
|
|
301
204
|
forwarded: string[];
|
|
302
205
|
};
|
|
303
|
-
}
|
|
304
|
-
|
|
206
|
+
}
|
|
207
|
+
interface TSearchParamsCache {
|
|
305
208
|
raw?: string;
|
|
306
209
|
urlSearchParams?: WooksURLSearchParams;
|
|
307
|
-
}
|
|
210
|
+
}
|
|
308
211
|
|
|
309
212
|
declare function useCookies(): {
|
|
310
213
|
rawCookies: string | undefined;
|
|
@@ -312,10 +215,8 @@ declare function useCookies(): {
|
|
|
312
215
|
};
|
|
313
216
|
declare function useSetCookies(): {
|
|
314
217
|
setCookie: (name: string, value: string, attrs?: Partial<TCookieAttributes>) => void;
|
|
315
|
-
getCookie: <K2 extends string
|
|
316
|
-
|
|
317
|
-
}[K2];
|
|
318
|
-
removeCookie: <K2_1 extends string | number>(key2: K2_1) => void;
|
|
218
|
+
getCookie: <K2 extends string>(key2: K2) => TSetCookieData | undefined;
|
|
219
|
+
removeCookie: <K2_1 extends string>(key2: K2_1) => void;
|
|
319
220
|
clearCookies: () => void;
|
|
320
221
|
cookies: () => string[];
|
|
321
222
|
};
|
|
@@ -325,6 +226,92 @@ declare function useSetCookie(name: string): {
|
|
|
325
226
|
} & _wooksjs_event_core.THook<string, "value"> & _wooksjs_event_core.THook<TCookieAttributes, "attrs">;
|
|
326
227
|
type TCookieHook = ReturnType<typeof useSetCookie>;
|
|
327
228
|
|
|
229
|
+
declare function useAccept(): {
|
|
230
|
+
accept: string | undefined;
|
|
231
|
+
accepts: (mime: string) => unknown;
|
|
232
|
+
acceptsJson: () => unknown;
|
|
233
|
+
acceptsXml: () => unknown;
|
|
234
|
+
acceptsText: () => unknown;
|
|
235
|
+
acceptsHtml: () => unknown;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
declare function useAuthorization(): {
|
|
239
|
+
authorization: string | undefined;
|
|
240
|
+
authType: () => string | null;
|
|
241
|
+
authRawCredentials: () => string | null;
|
|
242
|
+
isBasic: () => boolean;
|
|
243
|
+
isBearer: () => boolean;
|
|
244
|
+
basicCredentials: () => {
|
|
245
|
+
username: string;
|
|
246
|
+
password: string;
|
|
247
|
+
} | null;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
interface TCacheControl {
|
|
251
|
+
mustRevalidate?: boolean;
|
|
252
|
+
noCache?: boolean | string;
|
|
253
|
+
noStore?: boolean;
|
|
254
|
+
noTransform?: boolean;
|
|
255
|
+
public?: boolean;
|
|
256
|
+
private?: boolean | string;
|
|
257
|
+
proxyRevalidate?: boolean;
|
|
258
|
+
maxAge?: number | TTimeMultiString;
|
|
259
|
+
sMaxage?: number | TTimeMultiString;
|
|
260
|
+
}
|
|
261
|
+
declare function renderCacheControl(data: TCacheControl): string;
|
|
262
|
+
|
|
263
|
+
declare function useSetCacheControl(): {
|
|
264
|
+
setExpires: (value: Date | string | number) => void;
|
|
265
|
+
setAge: (value: number | TTimeMultiString) => void;
|
|
266
|
+
setPragmaNoCache: (value?: boolean) => void;
|
|
267
|
+
setCacheControl: (data: TCacheControl) => void;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
declare function useHeaders(): IncomingHttpHeaders;
|
|
271
|
+
declare function useSetHeaders(): {
|
|
272
|
+
setHeader: (name: string, value: string | number) => void;
|
|
273
|
+
getHeader: <K2 extends string>(key2: K2) => string | string[] | undefined;
|
|
274
|
+
removeHeader: <K2_1 extends string>(key2: K2_1) => void;
|
|
275
|
+
setContentType: (value: string) => void;
|
|
276
|
+
headers: () => Record<string, string | string[]>;
|
|
277
|
+
enableCors: (origin?: string) => void;
|
|
278
|
+
};
|
|
279
|
+
declare function useSetHeader(name: string): {
|
|
280
|
+
value: string | string[];
|
|
281
|
+
isDefined: boolean;
|
|
282
|
+
};
|
|
283
|
+
type THeaderHook = ReturnType<typeof useSetHeader>;
|
|
284
|
+
|
|
285
|
+
declare function useRequest(): {
|
|
286
|
+
rawRequest: http.IncomingMessage;
|
|
287
|
+
url: string | undefined;
|
|
288
|
+
method: string | undefined;
|
|
289
|
+
headers: http.IncomingHttpHeaders;
|
|
290
|
+
rawBody: () => Promise<Buffer>;
|
|
291
|
+
reqId: () => string;
|
|
292
|
+
getIp: (options?: {
|
|
293
|
+
trustProxy: boolean;
|
|
294
|
+
}) => string;
|
|
295
|
+
getIpList: () => {
|
|
296
|
+
remoteIp: string;
|
|
297
|
+
forwarded: string[];
|
|
298
|
+
};
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
interface TUseResponseOptions {
|
|
302
|
+
passthrough: boolean;
|
|
303
|
+
}
|
|
304
|
+
declare function useResponse(): {
|
|
305
|
+
rawResponse: (options?: TUseResponseOptions) => http.ServerResponse<http.IncomingMessage>;
|
|
306
|
+
hasResponded: () => boolean;
|
|
307
|
+
status: ((code?: EHttpStatusCode) => EHttpStatusCode) & _wooksjs_event_core.THook<EHttpStatusCode, "value">;
|
|
308
|
+
};
|
|
309
|
+
declare function useStatus(): {
|
|
310
|
+
value: EHttpStatusCode;
|
|
311
|
+
isDefined: boolean;
|
|
312
|
+
};
|
|
313
|
+
type TStatusHook = ReturnType<typeof useStatus>;
|
|
314
|
+
|
|
328
315
|
declare function useSearchParams(): {
|
|
329
316
|
rawSearchParams: () => string;
|
|
330
317
|
urlSearchParams: () => WooksURLSearchParams;
|
|
@@ -366,16 +353,10 @@ declare class BaseHttpResponse<BodyType = unknown> {
|
|
|
366
353
|
respond(): Promise<unknown>;
|
|
367
354
|
}
|
|
368
355
|
|
|
369
|
-
declare class HttpErrorRenderer extends BaseHttpResponseRenderer<TWooksErrorBodyExt> {
|
|
370
|
-
renderHtml(response: BaseHttpResponse<TWooksErrorBodyExt>): string;
|
|
371
|
-
renderText(response: BaseHttpResponse<TWooksErrorBodyExt>): string;
|
|
372
|
-
renderJson(response: BaseHttpResponse<TWooksErrorBodyExt>): string;
|
|
373
|
-
render(response: BaseHttpResponse<TWooksErrorBodyExt>): string;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
356
|
declare class HttpError<T extends TWooksErrorBody = TWooksErrorBody> extends Error {
|
|
377
357
|
protected code: THttpErrorCodes;
|
|
378
358
|
protected _body: string | T;
|
|
359
|
+
name: string;
|
|
379
360
|
constructor(code?: THttpErrorCodes, _body?: string | T);
|
|
380
361
|
get body(): TWooksErrorBodyExt;
|
|
381
362
|
protected renderer?: HttpErrorRenderer;
|
|
@@ -391,10 +372,12 @@ interface TWooksErrorBodyExt extends TWooksErrorBody {
|
|
|
391
372
|
error: string;
|
|
392
373
|
}
|
|
393
374
|
|
|
394
|
-
declare
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
375
|
+
declare class HttpErrorRenderer extends BaseHttpResponseRenderer<TWooksErrorBodyExt> {
|
|
376
|
+
renderHtml(response: BaseHttpResponse<TWooksErrorBodyExt>): string;
|
|
377
|
+
renderText(response: BaseHttpResponse<TWooksErrorBodyExt>): string;
|
|
378
|
+
renderJson(response: BaseHttpResponse<TWooksErrorBodyExt>): string;
|
|
379
|
+
render(response: BaseHttpResponse<TWooksErrorBodyExt>): string;
|
|
380
|
+
}
|
|
398
381
|
|
|
399
382
|
declare function createHttpContext(data: THttpEventData, options: TEventOptions): {
|
|
400
383
|
getCtx: () => THttpContextStore & _wooksjs_event_core.TGenericContextStore<THttpEventData>;
|
|
@@ -408,7 +391,7 @@ declare function createHttpContext(data: THttpEventData, options: TEventOptions)
|
|
|
408
391
|
};
|
|
409
392
|
init: <K2_1 extends keyof Required<THttpContextStore & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>(key2: K2_1, getter: () => Required<Required<THttpContextStore & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>[K2_1]) => Required<Required<THttpContextStore & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>[K2_1];
|
|
410
393
|
set: <K2_2 extends keyof Required<THttpContextStore & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>(key2: K2_2, v: Required<(THttpContextStore & _wooksjs_event_core.TGenericContextStore<THttpEventData>)[K]>[K2_2]) => Required<(THttpContextStore & _wooksjs_event_core.TGenericContextStore<THttpEventData>)[K]>[K2_2];
|
|
411
|
-
get: <K2_3 extends keyof Required<THttpContextStore & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>(key2: K2_3) => Required<THttpContextStore & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K][K2_3];
|
|
394
|
+
get: <K2_3 extends keyof Required<THttpContextStore & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>(key2: K2_3) => Required<THttpContextStore & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K][K2_3] | undefined;
|
|
412
395
|
has: <K2_4 extends keyof Required<THttpContextStore & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>(key2: K2_4) => boolean;
|
|
413
396
|
del: <K2_5 extends keyof Required<THttpContextStore & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>(key2: K2_5) => void;
|
|
414
397
|
entries: () => [string, unknown][];
|
|
@@ -433,7 +416,7 @@ declare function useHttpContext<T extends TEmpty>(): {
|
|
|
433
416
|
};
|
|
434
417
|
init: <K2_1 extends keyof Required<THttpContextStore & T & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>(key2: K2_1, getter: () => Required<Required<THttpContextStore & T & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>[K2_1]) => Required<Required<THttpContextStore & T & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>[K2_1];
|
|
435
418
|
set: <K2_2 extends keyof Required<THttpContextStore & T & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>(key2: K2_2, v: Required<(THttpContextStore & T & _wooksjs_event_core.TGenericContextStore<THttpEventData>)[K]>[K2_2]) => Required<(THttpContextStore & T & _wooksjs_event_core.TGenericContextStore<THttpEventData>)[K]>[K2_2];
|
|
436
|
-
get: <K2_3 extends keyof Required<THttpContextStore & T & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>(key2: K2_3) => Required<THttpContextStore & T & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K][K2_3];
|
|
419
|
+
get: <K2_3 extends keyof Required<THttpContextStore & T & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>(key2: K2_3) => Required<THttpContextStore & T & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K][K2_3] | undefined;
|
|
437
420
|
has: <K2_4 extends keyof Required<THttpContextStore & T & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>(key2: K2_4) => boolean;
|
|
438
421
|
del: <K2_5 extends keyof Required<THttpContextStore & T & _wooksjs_event_core.TGenericContextStore<THttpEventData>>[K]>(key2: K2_5) => void;
|
|
439
422
|
entries: () => [string, unknown][];
|
|
@@ -443,10 +426,15 @@ declare function useHttpContext<T extends TEmpty>(): {
|
|
|
443
426
|
setStore: <K_2 extends keyof THttpContextStore | keyof _wooksjs_event_core.TGenericContextStore<THttpEventData> | keyof T>(key: K_2, v: (THttpContextStore & T & _wooksjs_event_core.TGenericContextStore<THttpEventData>)[K_2]) => void;
|
|
444
427
|
};
|
|
445
428
|
|
|
429
|
+
declare function createWooksResponder(renderer?: TWooksResponseRenderer<any>, errorRenderer?: TWooksResponseRenderer<any>): {
|
|
430
|
+
createResponse: <T = unknown>(data: T) => BaseHttpResponse<TWooksErrorBodyExt | T> | null;
|
|
431
|
+
respond: (data: unknown) => Promise<unknown> | undefined;
|
|
432
|
+
};
|
|
433
|
+
|
|
446
434
|
interface TWooksHttpOptions {
|
|
447
435
|
logger?: TConsoleBase;
|
|
448
436
|
eventOptions?: TEventOptions;
|
|
449
|
-
onNotFound?: TWooksHandler
|
|
437
|
+
onNotFound?: TWooksHandler;
|
|
450
438
|
router?: TWooksOptions['router'];
|
|
451
439
|
}
|
|
452
440
|
declare class WooksHttp extends WooksAdapterBase {
|
|
@@ -467,7 +455,15 @@ declare class WooksHttp extends WooksAdapterBase {
|
|
|
467
455
|
*
|
|
468
456
|
* Use this only if you rely on Wooks server.
|
|
469
457
|
*/
|
|
470
|
-
listen(
|
|
458
|
+
listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this;
|
|
459
|
+
listen(port?: number, hostname?: string, listeningListener?: () => void): this;
|
|
460
|
+
listen(port?: number, backlog?: number, listeningListener?: () => void): this;
|
|
461
|
+
listen(port?: number, listeningListener?: () => void): this;
|
|
462
|
+
listen(path: string, backlog?: number, listeningListener?: () => void): this;
|
|
463
|
+
listen(path: string, listeningListener?: () => void): this;
|
|
464
|
+
listen(options: ListenOptions, listeningListener?: () => void): this;
|
|
465
|
+
listen(handle: any, backlog?: number, listeningListener?: () => void): this;
|
|
466
|
+
listen(handle: any, listeningListener?: () => void): this;
|
|
471
467
|
/**
|
|
472
468
|
* Stops the server if it was attached or passed via argument
|
|
473
469
|
* @param server
|
|
@@ -479,7 +475,7 @@ declare class WooksHttp extends WooksAdapterBase {
|
|
|
479
475
|
* See attachServer method docs
|
|
480
476
|
* @returns Server
|
|
481
477
|
*/
|
|
482
|
-
getServer():
|
|
478
|
+
getServer(): Server<typeof IncomingMessage, typeof ServerResponse> | undefined;
|
|
483
479
|
/**
|
|
484
480
|
* Attaches http(s) server instance
|
|
485
481
|
* to Wooks.
|
|
@@ -506,7 +502,7 @@ declare class WooksHttp extends WooksAdapterBase {
|
|
|
506
502
|
* ```
|
|
507
503
|
*/
|
|
508
504
|
getServerCb(): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
509
|
-
protected processHandlers(handlers: TWooksHandler
|
|
505
|
+
protected processHandlers(handlers: TWooksHandler[]): Promise<void>;
|
|
510
506
|
}
|
|
511
507
|
/**
|
|
512
508
|
* Factory for WooksHttp App
|