Fastify · Schema

Fastify Plugin and Server Configuration

JSON Schema for Fastify server instance options and plugin configuration patterns.

FrameworksHigh PerformanceJavaScriptJSON SchemaNode.jsTypeScript

Properties

Name Type Description
logger object Logger configuration (Pino).
ajv object Ajv (JSON Schema validator) configuration.
http2 boolean Enable HTTP/2 support.
https object HTTPS/TLS configuration.
connectionTimeout integer Connection timeout in milliseconds.
keepAliveTimeout integer Keep-alive timeout in milliseconds.
maxParamLength integer Maximum parameter length for URL params.
bodyLimit integer Default maximum body size in bytes.
caseSensitive boolean Case-sensitive routing.
ignoreTrailingSlash boolean Ignore trailing slashes in routes.
ignoreDuplicateSlashes boolean Ignore duplicate slashes in routes.
disableRequestLogging boolean Disable automatic request logging.
requestIdHeader string Header name to use for request ID.
requestIdLogLabel string Label for request ID in logs.
pluginTimeout integer Plugin load timeout in milliseconds.
forceCloseConnections object Force close connections on server close.
trustProxy object Trust proxy configuration.
return503OnClosing boolean Return 503 when server is closing.
View JSON Schema on GitHub

JSON Schema

fastify-plugin-config.json Raw ↑
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/api-evangelist/fastify/json-schema/fastify-plugin-config.json",
  "title": "Fastify Plugin and Server Configuration",
  "description": "JSON Schema for Fastify server instance options and plugin configuration patterns.",
  "type": "object",
  "properties": {
    "logger": {
      "description": "Logger configuration (Pino).",
      "oneOf": [
        { "type": "boolean" },
        {
          "type": "object",
          "properties": {
            "level": {
              "type": "string",
              "enum": ["trace", "debug", "info", "warn", "error", "fatal", "silent"],
              "default": "info"
            },
            "prettyPrint": {
              "type": "boolean",
              "description": "Enable pretty printing (dev only).",
              "default": false
            },
            "serializers": {
              "type": "object",
              "description": "Custom serializers for log fields.",
              "additionalProperties": true
            },
            "redact": {
              "type": "array",
              "description": "Paths to redact from logs.",
              "items": {
                "type": "string"
              }
            },
            "file": {
              "type": "string",
              "description": "Log output file path."
            },
            "transport": {
              "type": "object",
              "description": "Pino transport configuration.",
              "properties": {
                "target": {
                  "type": "string"
                },
                "options": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "additionalProperties": true
            }
          },
          "additionalProperties": true
        }
      ]
    },
    "ajv": {
      "type": "object",
      "description": "Ajv (JSON Schema validator) configuration.",
      "properties": {
        "customOptions": {
          "type": "object",
          "description": "Custom Ajv options.",
          "properties": {
            "removeAdditional": {
              "type": "boolean",
              "default": false
            },
            "useDefaults": {
              "type": "boolean",
              "default": true
            },
            "coerceTypes": {
              "type": "boolean",
              "default": true
            },
            "allErrors": {
              "type": "boolean",
              "default": false
            }
          },
          "additionalProperties": true
        },
        "plugins": {
          "type": "array",
          "description": "Ajv plugins to load.",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": true
    },
    "http2": {
      "type": "boolean",
      "description": "Enable HTTP/2 support.",
      "default": false
    },
    "https": {
      "type": "object",
      "description": "HTTPS/TLS configuration.",
      "properties": {
        "key": {
          "type": "string",
          "description": "Path to TLS private key or key contents."
        },
        "cert": {
          "type": "string",
          "description": "Path to TLS certificate or certificate contents."
        },
        "allowHTTP1": {
          "type": "boolean",
          "description": "Allow HTTP/1.1 fallback with HTTP/2.",
          "default": true
        }
      },
      "additionalProperties": true
    },
    "connectionTimeout": {
      "type": "integer",
      "description": "Connection timeout in milliseconds.",
      "default": 0
    },
    "keepAliveTimeout": {
      "type": "integer",
      "description": "Keep-alive timeout in milliseconds.",
      "default": 72000
    },
    "maxParamLength": {
      "type": "integer",
      "description": "Maximum parameter length for URL params.",
      "default": 100
    },
    "bodyLimit": {
      "type": "integer",
      "description": "Default maximum body size in bytes.",
      "default": 1048576
    },
    "caseSensitive": {
      "type": "boolean",
      "description": "Case-sensitive routing.",
      "default": true
    },
    "ignoreTrailingSlash": {
      "type": "boolean",
      "description": "Ignore trailing slashes in routes.",
      "default": false
    },
    "ignoreDuplicateSlashes": {
      "type": "boolean",
      "description": "Ignore duplicate slashes in routes.",
      "default": false
    },
    "disableRequestLogging": {
      "type": "boolean",
      "description": "Disable automatic request logging.",
      "default": false
    },
    "requestIdHeader": {
      "type": "string",
      "description": "Header name to use for request ID.",
      "default": "request-id"
    },
    "requestIdLogLabel": {
      "type": "string",
      "description": "Label for request ID in logs.",
      "default": "reqId"
    },
    "pluginTimeout": {
      "type": "integer",
      "description": "Plugin load timeout in milliseconds.",
      "default": 10000
    },
    "forceCloseConnections": {
      "description": "Force close connections on server close.",
      "oneOf": [
        { "type": "boolean" },
        { "type": "string", "const": "idle" }
      ],
      "default": "idle"
    },
    "trustProxy": {
      "description": "Trust proxy configuration.",
      "oneOf": [
        { "type": "boolean" },
        { "type": "string" },
        { "type": "integer" },
        { "type": "array", "items": { "type": "string" } }
      ],
      "default": false
    },
    "return503OnClosing": {
      "type": "boolean",
      "description": "Return 503 when server is closing.",
      "default": true
    }
  },
  "additionalProperties": true
}