forked from fastify/fastify-reply-from
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
95 lines (88 loc) · 2.38 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
95
/// <reference types="node" />
import {
FastifyRequest,
FastifyReply,
FastifyPlugin,
RawReplyDefaultExpression,
RawServerBase,
RequestGenericInterface
} from 'fastify';
import {
IncomingMessage,
IncomingHttpHeaders,
RequestOptions,
AgentOptions,
Agent,
} from "http";
import {
RequestOptions as SecureRequestOptions,
AgentOptions as SecureAgentOptions,
Agent as SecureAgent
} from "https";
import {
Http2ServerRequest,
IncomingHttpHeaders as Http2IncomingHttpHeaders,
ClientSessionRequestOptions,
ClientSessionOptions,
SecureClientSessionOptions,
} from "http2";
import { Pool } from 'undici'
export interface FastifyReplyFromHooks {
queryString?: { [key: string]: unknown };
contentType?: string;
onResponse?: (
request: FastifyRequest<RequestGenericInterface, RawServerBase>,
reply: FastifyReply<RawServerBase>,
res: RawReplyDefaultExpression<RawServerBase>
) => void;
onError?: (
reply: FastifyReply<RawServerBase>,
error: { error: Error }
) => void;
body?: unknown;
rewriteHeaders?: (
headers: Http2IncomingHttpHeaders | IncomingHttpHeaders
) => Http2IncomingHttpHeaders | IncomingHttpHeaders;
rewriteRequestHeaders?: (
req: Http2ServerRequest | IncomingMessage,
headers: Http2IncomingHttpHeaders | IncomingHttpHeaders
) => Http2IncomingHttpHeaders | IncomingHttpHeaders;
getUpstream?: (
req: Http2ServerRequest | IncomingMessage,
base: string
) => string;
}
declare module "fastify" {
interface FastifyReply {
from(
source?: string,
opts?: FastifyReplyFromHooks
): void;
}
}
interface Http2Options {
sessionTimeout?: number;
requestTimeout?: number;
sessionOptions?: ClientSessionOptions | SecureClientSessionOptions;
requestOptions?: ClientSessionRequestOptions;
}
interface HttpOptions {
agentOptions?: AgentOptions | SecureAgentOptions;
requestOptions?: RequestOptions | SecureRequestOptions;
agents?: { 'http:': Agent, 'https:': SecureAgent }
}
export interface FastifyReplyFromOptions {
base?: string;
cacheURLs?: number;
disableCache?: boolean;
http?: HttpOptions;
http2?: Http2Options | boolean;
undici?: Pool.Options;
keepAliveMsecs?: number;
maxFreeSockets?: number;
maxSockets?: number;
rejectUnauthorized?: boolean;
sessionTimeout?: number;
}
declare const fastifyReplyFrom: FastifyPlugin<FastifyReplyFromOptions>
export default fastifyReplyFrom;