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
httphttp2httpsconnectionTimeoutkeepAliveTimeoutforceCloseConnectionsmaxRequestsPerSocketrequestTimeoutbodyLimitonProtoPoisoningonConstructorPoisoningloggerloggerInstancedisableRequestLoggingserverFactoryrequestIdHeaderrequestIdLogLabelgenReqIdtrustProxypluginTimeoutexposeHeadRoutesreturn503OnClosingajvserializerOptshttp2SessionTimeoutframeworkErrorsclientErrorHandlerrewriteUrlallowErrorHandlerOverride- RouterOptions
- Instance
- Server Methods
- server
- after
- ready
- listen
- addresses
- routing
- route
- hasRoute
- findRoute
- close
- decorate*
- register
- addHook
- prefix
- pluginName
- hasPlugin
- listeningOrigin
- log
- version
- inject
- addHttpMethod
- addSchema
- getSchemas
- getSchema
- setReplySerializer
- setValidatorCompiler
- setSchemaErrorFormatter
- setSerializerCompiler
- validatorCompiler
- serializerCompiler
- schemaErrorFormatter
- schemaController
- setNotFoundHandler
- setErrorHandler
- setChildLoggerFactory
- setGenReqId
- addConstraintStrategy
- hasConstraintStrategy
- printRoutes
- printPlugins
- addContentTypeParser
- hasContentTypeParser
- removeContentTypeParser
- removeAllContentTypeParsers
- getDefaultJsonParser
- defaultTextParser
- errorHandler
- childLoggerFactory
- Symbol.asyncDispose
- 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.
connectionTimeout
- Default:
0(no timeout)
Defines the server timeout in milliseconds. See documentation for
server.timeout
property to understand
the effect of this option.
When serverFactory option is specified this option is ignored.
keepAliveTimeout
- Default:
72000(72 seconds)
Defines the server keep-alive timeout in milliseconds. See documentation for
server.keepAliveTimeout
property to
understand the effect of this option. This option only applies when HTTP/1 is in
use.
When serverFactory option is specified this option is ignored.