Server
Factory
The Fastify module exports a factory function that is used to create new
Fastify server
instances. This factory function accepts an
options object which is used to customize the resulting instance. This document
describes the properties available in that options object.
- Factory
http
http2
https
connectionTimeout
keepAliveTimeout
forceCloseConnections
maxRequestsPerSocket
requestTimeout
ignoreTrailingSlash
ignoreDuplicateSlashes
maxParamLength
bodyLimit
onProtoPoisoning
onConstructorPoisoning
logger
disableRequestLogging
serverFactory
jsonShorthand
caseSensitive
allowUnsafeRegex
requestIdHeader
requestIdLogLabel
genReqId
trustProxy
pluginTimeout
querystringParser
exposeHeadRoutes
constraints
return503OnClosing
ajv
serializerOpts
http2SessionTimeout
frameworkErrors
clientErrorHandler
rewriteUrl
- Instance
- Server Methods
- server
- after
- ready
- listen
- addresses
- getDefaultRoute
- setDefaultRoute
- routing
- route
- hasRoute
- close
- decorate*
- register
- addHook
- prefix
- pluginName
- hasPlugin
- listeningOrigin
- log
- version
- inject
- addSchema
- getSchemas
- getSchema
- setReplySerializer
- setValidatorCompiler
- setSchemaErrorFormatter
- setSerializerCompiler
- validatorCompiler
- serializerCompiler
- schemaErrorFormatter
- schemaController
- setNotFoundHandler
- setErrorHandler
- setChildLoggerFactory
- addConstraintStrategy
- hasConstraintStrategy
- printRoutes
- printPlugins
- addContentTypeParser
- hasContentTypeParser
- removeContentTypeParser
- removeAllContentTypeParsers
- getDefaultJsonParser
- defaultTextParser
- errorHandler
- childLoggerFactory
- initialConfig
- Server Methods
http
- Default:
null
An object used to configure the server's listening socket. The options
are the same as the Node.js core createServer
method.
This option is ignored if options http2
or
https
are set.
http2
- Default:
false
If true
Node.js core's
HTTP/2 module is
used for binding the socket.
https
- Default:
null
An object used to configure the server's listening socket for TLS. The options
are the same as the Node.js core createServer
method.
When this property is null
, the socket will not be configured for TLS.
This option also applies when the http2
option is set.