Home / File/ request.d.ts — fastify Source File

request.d.ts — fastify Source File

Architecture documentation for request.d.ts, a typescript file in the fastify codebase. 8 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  74948ea5_332c_2f4b_c31f_ea89e0b8fc66["request.d.ts"]
  3638cb41_31a7_7190_5c54_46a811f35dac["./context"]
  74948ea5_332c_2f4b_c31f_ea89e0b8fc66 --> 3638cb41_31a7_7190_5c54_46a811f35dac
  531c9fc1_aab6_113a_24da_d449700fa629["./instance"]
  74948ea5_332c_2f4b_c31f_ea89e0b8fc66 --> 531c9fc1_aab6_113a_24da_d449700fa629
  ee998eba_0ed8_8b67_66d6_d2f80d980a41["./logger"]
  74948ea5_332c_2f4b_c31f_ea89e0b8fc66 --> ee998eba_0ed8_8b67_66d6_d2f80d980a41
  6a6fa08e_3d60_0520_25ea_dea35398fc8f["./route"]
  74948ea5_332c_2f4b_c31f_ea89e0b8fc66 --> 6a6fa08e_3d60_0520_25ea_dea35398fc8f
  79072a34_3222_2b87_85da_7f07094af121["./schema"]
  74948ea5_332c_2f4b_c31f_ea89e0b8fc66 --> 79072a34_3222_2b87_85da_7f07094af121
  0ec7ea98_0ca5_a578_7447_eb9a7fa7cc31["./type-provider"]
  74948ea5_332c_2f4b_c31f_ea89e0b8fc66 --> 0ec7ea98_0ca5_a578_7447_eb9a7fa7cc31
  36d8862b_caf4_88a2_ba4d_4f7ed0738291["./utils"]
  74948ea5_332c_2f4b_c31f_ea89e0b8fc66 --> 36d8862b_caf4_88a2_ba4d_4f7ed0738291
  f01e81af_0f1c_2d30_7446_655520499bc3["ajv-compiler"]
  74948ea5_332c_2f4b_c31f_ea89e0b8fc66 --> f01e81af_0f1c_2d30_7446_655520499bc3
  style 74948ea5_332c_2f4b_c31f_ea89e0b8fc66 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { ErrorObject } from '@fastify/ajv-compiler'
import { FastifyContextConfig } from './context'
import { FastifyInstance } from './instance'
import { FastifyBaseLogger } from './logger'
import { FastifyRouteConfig, RouteGenericInterface, RouteHandlerMethod } from './route'
import { FastifySchema } from './schema'
import { FastifyRequestType, FastifyTypeProvider, FastifyTypeProviderDefault, ResolveFastifyRequestType } from './type-provider'
import { ContextConfigDefault, HTTPMethods, RawRequestDefaultExpression, RawServerBase, RawServerDefault, RequestBodyDefault, RequestHeadersDefault, RequestParamsDefault, RequestQuerystringDefault } from './utils'

type HTTPRequestPart = 'body' | 'query' | 'querystring' | 'params' | 'headers'
export interface RequestGenericInterface {
  Body?: RequestBodyDefault;
  Querystring?: RequestQuerystringDefault;
  Params?: RequestParamsDefault;
  Headers?: RequestHeadersDefault;
}

export interface ValidationFunction {
  (input: any): boolean
  errors?: null | ErrorObject[];
}

export interface RequestRouteOptions<ContextConfig = ContextConfigDefault, SchemaCompiler = FastifySchema> {
  method: HTTPMethods | HTTPMethods[];
  // `url` can be `undefined` for instance when `request.is404` is true
  url: string | undefined;
  bodyLimit: number;
  attachValidation: boolean;
  logLevel: string;
  exposeHeadRoute: boolean;
  prefixTrailingSlash: string;
  config: FastifyContextConfig & FastifyRouteConfig & ContextConfig;
  schema?: SchemaCompiler; // it is empty for 404 requests
  handler: RouteHandlerMethod;
  version?: string;
}

/**
 * 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>,
  SchemaCompiler extends FastifySchema = FastifySchema,
  TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
  ContextConfig = ContextConfigDefault,
  Logger extends FastifyBaseLogger = FastifyBaseLogger,
  RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>
// ^ Temporary Note: RequestType has been re-ordered to be the last argument in
//   generic list. This generic argument is now considered optional as it can be
//   automatically inferred from the SchemaCompiler, RouteGeneric and TypeProvider
//   arguments. Implementations that already pass this argument can either omit
//   the RequestType (preferred) or swap Logger and RequestType arguments when
//   creating custom types of FastifyRequest. Related issue #4123
> {
  id: string;
  params: RequestType['params']; // deferred inference
  raw: RawRequest;
  query: RequestType['query'];
  headers: RawRequest['headers'] & RequestType['headers']; // this enables the developer to extend the existing http(s|2) headers list
  log: Logger;
  server: FastifyInstance;
  body: RequestType['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 & RouteGeneric['Headers']; // this enables the developer to extend the existing http(s|2) headers list
  readonly ip: string;
  readonly ips?: string[];
  readonly host: string;
  readonly port: number;
  readonly hostname: string;
  readonly url: string;
  readonly originalUrl: string;
  readonly protocol: 'http' | 'https';
  readonly method: string;
  readonly routeOptions: Readonly<RequestRouteOptions<ContextConfig, SchemaCompiler>>
  readonly is404: boolean;
  readonly socket: RawRequest['socket'];

  getValidationFunction(httpPart: HTTPRequestPart): ValidationFunction
  getValidationFunction(schema: { [key: string]: any }): ValidationFunction
  compileValidationSchema(schema: { [key: string]: any }, httpPart?: HTTPRequestPart): ValidationFunction
  validateInput(input: any, schema: { [key: string]: any }, httpPart?: HTTPRequestPart): boolean
  validateInput(input: any, httpPart?: HTTPRequestPart): boolean
  getDecorator<T>(name: string | symbol): T;
  setDecorator<T = unknown>(name: string | symbol, value: T): void;
}

Domain

Dependencies

  • ./context
  • ./instance
  • ./logger
  • ./route
  • ./schema
  • ./type-provider
  • ./utils
  • ajv-compiler

Frequently Asked Questions

What does request.d.ts do?
request.d.ts is a source file in the fastify codebase, written in typescript. It belongs to the CoreKernel domain.
What does request.d.ts depend on?
request.d.ts imports 8 module(s): ./context, ./instance, ./logger, ./route, ./schema, ./type-provider, ./utils, ajv-compiler.
Where is request.d.ts in the architecture?
request.d.ts is located at types/request.d.ts (domain: CoreKernel, directory: types).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free