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

schema.d.ts — fastify Source File

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

File typescript CoreKernel InstanceFactory 3 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  d2936c5d_61ff_9b98_1597_9545d4d02b8e["schema.d.ts"]
  2bf9986b_b7fb_0c78_f075_72fbe6f4672b["fastify.js"]
  d2936c5d_61ff_9b98_1597_9545d4d02b8e --> 2bf9986b_b7fb_0c78_f075_72fbe6f4672b
  f01e81af_0f1c_2d30_7446_655520499bc3["ajv-compiler"]
  d2936c5d_61ff_9b98_1597_9545d4d02b8e --> f01e81af_0f1c_2d30_7446_655520499bc3
  7badc767_6ded_e9d1_fc52_2d169f82191e["fast-json-stringify-compiler"]
  d2936c5d_61ff_9b98_1597_9545d4d02b8e --> 7badc767_6ded_e9d1_fc52_2d169f82191e
  style d2936c5d_61ff_9b98_1597_9545d4d02b8e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { ValidatorFactory } from '@fastify/ajv-compiler'
import { SerializerFactory } from '@fastify/fast-json-stringify-compiler'
import { FastifyInstance, SafePromiseLike } from '../fastify'
/**
 * Schemas in Fastify follow the JSON-Schema standard. For this reason
 * we have opted to not ship strict schema based types. Instead we provide
 * an example in our documentation on how to solve this problem. Check it
 * out here: https://github.com/fastify/fastify/blob/main/docs/Reference/TypeScript.md#json-schema
 */
export interface FastifySchema {
  body?: unknown;
  querystring?: unknown;
  params?: unknown;
  headers?: unknown;
  response?: unknown;
}

export interface FastifyRouteSchemaDef<T> {
  schema: T;
  method: string;
  url: string;
  httpPart?: string;
  httpStatus?: string;
  contentType?: string;
}

export interface FastifySchemaValidationError {
  keyword: string;
  instancePath: string;
  schemaPath: string;
  params: Record<string, unknown>;
  message?: string;
}

export interface FastifyValidationResult {
  (data: any): boolean | SafePromiseLike<any> | { error?: Error | FastifySchemaValidationError[], value?: any }
  errors?: FastifySchemaValidationError[] | null;
}

/**
 * Compiler for FastifySchema Type
 */
export type FastifySchemaCompiler<T> = (routeSchema: FastifyRouteSchemaDef<T>) => FastifyValidationResult

export type FastifySerializerCompiler<T> = (routeSchema: FastifyRouteSchemaDef<T>) => (data: any) => string

export interface FastifySchemaControllerOptions {
  bucket?: (parentSchemas?: unknown) => {
    add(schema: unknown): FastifyInstance;
    getSchema(schemaId: string): unknown;
    getSchemas(): Record<string, unknown>;
  };
  compilersFactory?: {
    buildValidator?: ValidatorFactory;
    buildSerializer?: SerializerFactory;
  };
}

export type SchemaErrorDataVar = 'body' | 'headers' | 'params' | 'querystring'

export type SchemaErrorFormatter = (errors: FastifySchemaValidationError[], dataVar: SchemaErrorDataVar) => Error

Domain

Subdomains

Dependencies

  • ajv-compiler
  • fast-json-stringify-compiler
  • fastify.js

Frequently Asked Questions

What does schema.d.ts do?
schema.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 schema.d.ts?
schema.d.ts defines 4 function(s): Error, FastifyValidationResult, parentSchemas, routeSchema.
What does schema.d.ts depend on?
schema.d.ts imports 3 module(s): ajv-compiler, fast-json-stringify-compiler, fastify.js.
Where is schema.d.ts in the architecture?
schema.d.ts is located at types/schema.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