forked from fastify/fastify-reply-from
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
94 lines (84 loc) · 2.56 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/// <reference types="node" />
import * as fastify from "fastify";
import {
IncomingMessage,
IncomingHttpHeaders,
RequestOptions,
AgentOptions,
} from "http";
import {
RequestOptions as SecureRequestOptions,
AgentOptions as SecureAgentOptions,
} from "https";
import {
Http2ServerRequest,
IncomingHttpHeaders as Http2IncomingHttpHeaders,
ClientSessionRequestOptions,
ClientSessionOptions,
SecureClientSessionOptions,
} from "http2";
declare function fastifyReplyFrom<HttpServer, HttpRequest, HttpResponse>(
instance: fastify.FastifyInstance<HttpServer, HttpRequest, HttpResponse>,
opts: fastifyReplyFrom.ReplyFromOptions<
HttpServer,
HttpRequest,
HttpResponse
>,
callback?: (err?: Error) => void
): void;
interface Http2Options {
sessionTimeout?: number;
requestTimeout?: number;
sessionOptions?: ClientSessionOptions | SecureClientSessionOptions;
requestOptions?: ClientSessionRequestOptions;
}
interface HttpOptions {
agentOptions?: AgentOptions | SecureAgentOptions;
requestOptions?: RequestOptions | SecureRequestOptions;
}
declare namespace fastifyReplyFrom {
interface ReplyFromOptions<HttpServer, HttpRequest, HttpResponse>
extends fastify.RegisterOptions<HttpServer, HttpRequest, HttpResponse> {
base?: string;
cacheURLs?: number;
http?: HttpOptions;
http2?: Http2Options | boolean;
undici?: unknown; // undici has no TS declarations yet
keepAliveMsecs?: number;
maxFreeSockets?: number;
maxSockets?: number;
rejectUnauthorized?: boolean;
sessionTimeout?: number;
}
}
export = fastifyReplyFrom;
declare module "fastify" {
interface FastifyReply<HttpResponse> {
from(
source?: string,
opts?: {
queryString?: { [key: string]: unknown };
contentType?: string;
onResponse?: (
request: FastifyRequest,
reply: FastifyReply<HttpResponse>,
res: unknown
) => void;
body?: unknown;
rewriteHeaders?: (
headers: Http2IncomingHttpHeaders | IncomingHttpHeaders
) => Http2IncomingHttpHeaders | IncomingHttpHeaders;
rewriteRequestHeaders?: (
req: Http2ServerRequest | IncomingMessage,
headers: Http2IncomingHttpHeaders | IncomingHttpHeaders
) => Http2IncomingHttpHeaders | IncomingHttpHeaders;
logProxyError?: (
log: unknown,
err: Error
) => void;
logProxyRequest?: (log: unknown, source: string, requestConfig: unknown) => void;
logProxyResponse?: (log: unknown, res: HttpResponse) => void;
}
): void;
}
}