UNPKG

859 BTypeScriptView Raw
1/**
2 * Schemas in Fastify follow the JSON-Schema standard. For this reason
3 * we have opted to not ship strict schema based types. Instead we provide
4 * an example in our documentation on how to solve this problem. Check it
5 * out here:
6 */
7export interface FastifySchema {
8 body?: unknown;
9 querystring?: unknown;
10 params?: unknown;
11 headers?: unknown;
12 response?: unknown;
13}
14
15export interface FastifyRouteSchemaDef {
16 schema: FastifySchema;
17 method: string;
18 url: string;
19 httpPart?: string;
20 httpStatus?: string;
21}
22
23export interface FastifyValidationResult {
24 errors?: FastifySchemaValidationError[] | null;
25}
26
27export interface FastifySchemaValidationError {
28 message?: string;
29 dataPath: string;
30}
31
32/**
33 * Compiler for FastifySchema Type
34 */
35export type FastifySchemaCompiler = (routeSchema: FastifyRouteSchemaDef) => FastifyValidationResult