Interface FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger, RequestType>

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.

interface FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger, RequestType> {
    body: RequestType["body"];
    connection: RawRequest["socket"];
    context: FastifyRequestContext<ContextConfig>;
    headers: RawRequest["headers"] & RequestType["headers"];
    hostname: string;
    id: string;
    ip: string;
    ips?: string[];
    is404: boolean;
    log: Logger;
    method: string;
    originalUrl: string;
    params: RequestType["params"];
    protocol: "https" | "http";
    query: RequestType["query"];
    raw: RawRequest;
    req: RawRequest & RouteGeneric["Headers"];
    routeConfig: FastifyContextConfig & FastifyRouteConfig & ContextConfig;
    routeOptions: Readonly<RequestRouteOptions<ContextConfig, SchemaCompiler>>;
    routeSchema?: FastifySchema;
    routerMethod: string;
    routerPath: string;
    server: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>;
    socket: RawRequest["socket"];
    url: string;
    validationError?: Error & {
        validation: any;
        validationContext: string;
    };
    compileValidationSchema(schema, httpPart?): ValidationFunction;
    getValidationFunction(httpPart): ValidationFunction;
    getValidationFunction(schema): ValidationFunction;
    validateInput(input, schema, httpPart?): boolean;
    validateInput(input, httpPart?): boolean;
}

Type Parameters

Properties

body: RequestType["body"]
connection: RawRequest["socket"]
headers: RawRequest["headers"] & RequestType["headers"]
hostname: string
id: string
ip: string
ips?: string[]
is404: boolean
log: Logger
method: string
originalUrl: string
params: RequestType["params"]
protocol: "https" | "http"
query: RequestType["query"]
req: RawRequest & RouteGeneric["Headers"]

Deprecated

Use raw property

routeConfig: FastifyContextConfig & FastifyRouteConfig & ContextConfig
routeSchema?: FastifySchema
routerMethod: string
routerPath: string
socket: RawRequest["socket"]
url: string
validationError?: Error & {
    validation: any;
    validationContext: string;
}

in order for this to be used the user should ensure they have set the attachValidation option.

Type declaration

  • validation: any
  • validationContext: string

Methods

  • Parameters

    • input: any
    • schema: {
          [key: string]: any;
      }
      • [key: string]: any
    • Optional httpPart: HTTPRequestPart

    Returns boolean

  • Parameters

    Returns boolean