forked from fastify/fastify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
request.d.ts
50 lines (45 loc) · 1.87 KB
/
request.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
import { FastifyLoggerInstance } from './logger'
import { RawServerBase, RawServerDefault, RawRequestDefaultExpression, RequestBodyDefault, RequestQuerystringDefault, RequestParamsDefault, RequestHeadersDefault } from './utils'
import { RouteGenericInterface } from './route'
export interface RequestGenericInterface {
Body?: RequestBodyDefault;
Querystring?: RequestQuerystringDefault;
Params?: RequestParamsDefault;
Headers?: RequestHeadersDefault;
}
/**
* FastifyRequest is an instance of the standard http or http2 request objects.
* It defaults to http.IncomingMessage, and it also extends the relative request object.
*/
export interface FastifyRequest<
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
RawServer extends RawServerBase = RawServerDefault,
RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
> {
id: any;
params: RouteGeneric['Params'];
raw: RawRequest;
query: RouteGeneric['Querystring'];
log: FastifyLoggerInstance;
body: RouteGeneric['Body'];
/** in order for this to be used the user should ensure they have set the attachValidation option. */
validationError?: Error & { validation: any; validationContext: string };
/**
* @deprecated Use `raw` property
*/
readonly req: RawRequest;
readonly headers: RawRequest['headers'] & RouteGeneric['Headers']; // this enables the developer to extend the existing http(s|2) headers list
readonly ip: string;
readonly ips?: string[];
readonly hostname: string;
readonly url: string;
readonly protocol: 'http' | 'https';
readonly method: string;
readonly routerPath: string;
readonly routerMethod: string;
readonly is404: boolean;
readonly socket: RawRequest['socket'];
// Prefer `socket` over deprecated `connection` property in node 13.0.0 or higher
// @deprecated
readonly connection: RawRequest['socket'];
}