Home / File/ content-type-parser.d.ts — fastify Source File

content-type-parser.d.ts — fastify Source File

Architecture documentation for content-type-parser.d.ts, a typescript file in the fastify codebase. 5 imports, 0 dependents.

File typescript CoreKernel InstanceFactory 5 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  2e10524a_1fe8_dc22_f632_c2913eba9c82["content-type-parser.d.ts"]
  36d8862b_caf4_88a2_ba4d_4f7ed0738291["./utils"]
  2e10524a_1fe8_dc22_f632_c2913eba9c82 --> 36d8862b_caf4_88a2_ba4d_4f7ed0738291
  4285dbb5_245d_95e1_f339_579e1aa1d358["./request"]
  2e10524a_1fe8_dc22_f632_c2913eba9c82 --> 4285dbb5_245d_95e1_f339_579e1aa1d358
  6a6fa08e_3d60_0520_25ea_dea35398fc8f["./route"]
  2e10524a_1fe8_dc22_f632_c2913eba9c82 --> 6a6fa08e_3d60_0520_25ea_dea35398fc8f
  0ec7ea98_0ca5_a578_7447_eb9a7fa7cc31["./type-provider"]
  2e10524a_1fe8_dc22_f632_c2913eba9c82 --> 0ec7ea98_0ca5_a578_7447_eb9a7fa7cc31
  79072a34_3222_2b87_85da_7f07094af121["./schema"]
  2e10524a_1fe8_dc22_f632_c2913eba9c82 --> 79072a34_3222_2b87_85da_7f07094af121
  style 2e10524a_1fe8_dc22_f632_c2913eba9c82 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { RawServerBase, RawServerDefault, RawRequestDefaultExpression } from './utils'
import { FastifyRequest } from './request'
import { RouteGenericInterface } from './route'
import { FastifyTypeProvider, FastifyTypeProviderDefault } from './type-provider'
import { FastifySchema } from './schema'

type ContentTypeParserDoneFunction = (err: Error | null, body?: any) => void

/**
 * Body parser method that operators on request body
 */
export type FastifyBodyParser<
  RawBody extends string | Buffer,
  RawServer extends RawServerBase = RawServerDefault,
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
  SchemaCompiler extends FastifySchema = FastifySchema,
  TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault
> = ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>, rawBody: RawBody, done: ContentTypeParserDoneFunction) => void)
| ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>, rawBody: RawBody) => Promise<any>)

/**
 * Content Type Parser method that operates on request content
 */
export type FastifyContentTypeParser<
  RawServer extends RawServerBase = RawServerDefault,
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
  SchemaCompiler extends FastifySchema = FastifySchema,
  TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault
> = ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>, payload: RawRequest) => Promise<any>)
| ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>, payload: RawRequest, done: ContentTypeParserDoneFunction) => void)

/**
 * Natively, Fastify only supports 'application/json' and 'text/plain' content types. The default charset is utf-8. If you need to support different content types, you can use the addContentTypeParser API. The default JSON and/or plain text parser can be changed.
 */
export interface AddContentTypeParser<
  RawServer extends RawServerBase = RawServerDefault,
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
  SchemaCompiler extends FastifySchema = FastifySchema,
  TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault
> {
  (
    contentType: string | string[] | RegExp,
    opts: {
      bodyLimit?: number;
    },
    parser: FastifyContentTypeParser<RawServer, RawRequest, RouteGeneric, SchemaCompiler, TypeProvider>
  ): void;
  (contentType: string | string[] | RegExp, parser: FastifyContentTypeParser<RawServer, RawRequest, RouteGeneric, SchemaCompiler, TypeProvider>): void;
  <parseAs extends string | Buffer>(
    contentType: string | string[] | RegExp,
    opts: {
      parseAs: parseAs extends Buffer ? 'buffer' : 'string';
      bodyLimit?: number;
    },
    parser: FastifyBodyParser<parseAs, RawServer, RawRequest, RouteGeneric, SchemaCompiler, TypeProvider>
  ): void;
}

/**
 * Checks for a type parser of a content type
 */
export type hasContentTypeParser = (contentType: string | RegExp) => boolean

export type ProtoAction = 'error' | 'remove' | 'ignore'

export type ConstructorAction = 'error' | 'remove' | 'ignore'

export type getDefaultJsonParser = (onProtoPoisoning: ProtoAction, onConstructorPoisoning: ConstructorAction) => FastifyBodyParser<string>

export type removeContentTypeParser = (contentType: string | RegExp | (string | RegExp)[]) => void

export type removeAllContentTypeParsers = () => void

Domain

Subdomains

Dependencies

  • ./request
  • ./route
  • ./schema
  • ./type-provider
  • ./utils

Frequently Asked Questions

What does content-type-parser.d.ts do?
content-type-parser.d.ts is a source file in the fastify codebase, written in typescript. It belongs to the CoreKernel domain, InstanceFactory subdomain.
What functions are defined in content-type-parser.d.ts?
content-type-parser.d.ts defines 4 function(s): contentType, err, onProtoPoisoning, request.
What does content-type-parser.d.ts depend on?
content-type-parser.d.ts imports 5 module(s): ./request, ./route, ./schema, ./type-provider, ./utils.
Where is content-type-parser.d.ts in the architecture?
content-type-parser.d.ts is located at types/content-type-parser.d.ts (domain: CoreKernel, subdomain: InstanceFactory, directory: types).

Analyze Your Own Codebase

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

Try Supermodel Free