Skip to main content

AugmentedFastifyInstance

Api Code Documentation / Exports / types / AugmentedFastifyInstance

types.AugmentedFastifyInstance

Interface representing an extended fastify instance

Hierarchy

  • FastifyInstance

    AugmentedFastifyInstance

Table of contents

Properties

Methods

Properties

addContentTypeParser

addContentTypeParser: AddContentTypeParser<RawServerDefault, IncomingMessage, RouteGenericInterface, FastifySchema, FastifyTypeProviderDefault>

Add a content type parser

Inherited from

FastifyInstance.addContentTypeParser

Defined in

node_modules/fastify/types/instance.d.ts:542


all

all: RouteShorthandMethod<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.all

Defined in

node_modules/fastify/types/instance.d.ts:214


authenticate

authenticate: any

Defined in

src/types.ts:8


childLoggerFactory

childLoggerFactory: FastifyChildLoggerFactory<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Hook function that is called when creating a child logger instance for each request which allows for modifying or adding child logger bindings and logger options, or returning a completely custom child logger implementation.

Inherited from

FastifyInstance.childLoggerFactory

Defined in

node_modules/fastify/types/instance.d.ts:484


decorate

decorate: DecorationMethod<FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>, FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>>

Inherited from

FastifyInstance.decorate

Defined in

node_modules/fastify/types/instance.d.ts:151


decorateReply

decorateReply: DecorationMethod<FastifyReply<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGenericInterface, unknown, FastifySchema, FastifyTypeProviderDefault, unknown>, FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>>

Inherited from

FastifyInstance.decorateReply

Defined in

node_modules/fastify/types/instance.d.ts:153


decorateRequest

decorateRequest: DecorationMethod<FastifyRequest<RouteGenericInterface, RawServerDefault, IncomingMessage, FastifySchema, FastifyTypeProviderDefault, unknown, FastifyBaseLogger, ResolveFastifyRequestType<FastifyTypeProviderDefault, FastifySchema, RouteGenericInterface>>, FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>>

Inherited from

FastifyInstance.decorateRequest

Defined in

node_modules/fastify/types/instance.d.ts:152


defaultTextParser

defaultTextParser: FastifyBodyParser<string>

Fastify default plain text parser

Inherited from

FastifyInstance.defaultTextParser

Defined in

node_modules/fastify/types/instance.d.ts:559


delete

delete: RouteShorthandMethod<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.delete

Defined in

node_modules/fastify/types/instance.d.ts:211


errorHandler

errorHandler: (error: FastifyError, request: FastifyRequest<RouteGenericInterface, RawServerDefault, IncomingMessage, FastifySchema, FastifyTypeProviderDefault, unknown, FastifyBaseLogger, ResolveFastifyRequestType<FastifyTypeProviderDefault, FastifySchema, RouteGenericInterface>>, reply: FastifyReply<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGenericInterface, unknown, FastifySchema, FastifyTypeProviderDefault, unknown>) => void

Type declaration

▸ (error, request, reply): void

Fastify default error handler

Parameters
NameType
errorFastifyError
requestFastifyRequest<RouteGenericInterface, RawServerDefault, IncomingMessage, FastifySchema, FastifyTypeProviderDefault, unknown, FastifyBaseLogger, ResolveFastifyRequestType<FastifyTypeProviderDefault, FastifySchema, RouteGenericInterface>>
replyFastifyReply<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGenericInterface, unknown, FastifySchema, FastifyTypeProviderDefault, unknown>
Returns

void

Inherited from

FastifyInstance.errorHandler

Defined in

node_modules/fastify/types/instance.d.ts:470


get

get: RouteShorthandMethod<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.get

Defined in

node_modules/fastify/types/instance.d.ts:207


getDefaultJsonParser

getDefaultJsonParser: getDefaultJsonParser

Fastify default JSON parser

Inherited from

FastifyInstance.getDefaultJsonParser

Defined in

node_modules/fastify/types/instance.d.ts:555


hasContentTypeParser

hasContentTypeParser: hasContentTypeParser

Inherited from

FastifyInstance.hasContentTypeParser

Defined in

node_modules/fastify/types/instance.d.ts:543


head: RouteShorthandMethod<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.head

Defined in

node_modules/fastify/types/instance.d.ts:208


initialConfig

initialConfig: Readonly<{ allowUnsafeRegex?: boolean ; bodyLimit?: number ; caseSensitive?: boolean ; connectionTimeout?: number ; disableRequestLogging?: boolean ; forceCloseConnections?: boolean ; http2?: boolean ; http2SessionTimeout?: number ; https?: boolean | Readonly<{ allowHTTP1: boolean }> ; ignoreDuplicateSlashes?: boolean ; ignoreTrailingSlash?: boolean ; keepAliveTimeout?: number ; maxParamLength?: number ; onConstructorPoisoning?: ConstructorAction ; onProtoPoisoning?: ProtoAction ; pluginTimeout?: number ; requestIdHeader?: string | false ; requestIdLogLabel?: string }>

Frozen read-only object registering the initial options passed down by the user to the fastify instance

Inherited from

FastifyInstance.initialConfig

Defined in

node_modules/fastify/types/instance.d.ts:574


jwt

jwt: JWT

Inherited from

FastifyInstance.jwt

Defined in

node_modules/@fastify/jwt/types/jwt.d.ts:17


listeningOrigin

listeningOrigin: string

Inherited from

FastifyInstance.listeningOrigin

Defined in

node_modules/fastify/types/instance.d.ts:131


log

log: FastifyBaseLogger

Inherited from

FastifyInstance.log

Defined in

node_modules/fastify/types/instance.d.ts:130


metrics

metrics: IFastifyMetrics

Metrics interface

Inherited from

FastifyInstance.metrics

Defined in

node_modules/fastify-metrics/dist/index.d.ts:12


options

options: RouteShorthandMethod<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.options

Defined in

node_modules/fastify/types/instance.d.ts:212


patch

patch: RouteShorthandMethod<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.patch

Defined in

node_modules/fastify/types/instance.d.ts:213


pluginName

pluginName: string

Inherited from

FastifyInstance.pluginName

Defined in

node_modules/fastify/types/instance.d.ts:127


post

post: RouteShorthandMethod<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.post

Defined in

node_modules/fastify/types/instance.d.ts:209


prefix

prefix: string

Inherited from

FastifyInstance.prefix

Defined in

node_modules/fastify/types/instance.d.ts:128


put

put: RouteShorthandMethod<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.put

Defined in

node_modules/fastify/types/instance.d.ts:210


rateLimit

rateLimit: (options?: RateLimitOptions) => preHandlerAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGenericInterface, unknown, FastifySchema, FastifyTypeProviderDefault, FastifyBaseLogger>

Type declaration

▸ (options?): preHandlerAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGenericInterface, unknown, FastifySchema, FastifyTypeProviderDefault, FastifyBaseLogger>

Parameters
NameType
options?RateLimitOptions
Returns

preHandlerAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGenericInterface, unknown, FastifySchema, FastifyTypeProviderDefault, FastifyBaseLogger>

Inherited from

FastifyInstance.rateLimit

Defined in

node_modules/@fastify/rate-limit/types/index.d.ts:12


register

register: FastifyRegister<FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> & PromiseLike<undefined>, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>

Inherited from

FastifyInstance.register

Defined in

node_modules/fastify/types/instance.d.ts:195


removeAllContentTypeParsers

removeAllContentTypeParsers: removeAllContentTypeParsers

Remove all content type parsers, including the default ones

Inherited from

FastifyInstance.removeAllContentTypeParsers

Defined in

node_modules/fastify/types/instance.d.ts:551


removeContentTypeParser

removeContentTypeParser: removeContentTypeParser

Remove an existing content type parser

Inherited from

FastifyInstance.removeContentTypeParser

Defined in

node_modules/fastify/types/instance.d.ts:547


serializerCompiler

serializerCompiler: undefined | FastifySerializerCompiler<any>

Fastify schema serializer for all routes.

Inherited from

FastifyInstance.serializerCompiler

Defined in

node_modules/fastify/types/instance.d.ts:518


server

server: RawServerDefault

Inherited from

FastifyInstance.server

Defined in

node_modules/fastify/types/instance.d.ts:126


swagger

swagger: (opts?: { yaml?: false }) => Document<> & (opts: { yaml: true }) => string & (opts: { yaml: boolean }) => string | Document<>

Inherited from

FastifyInstance.swagger

Defined in

node_modules/@fastify/swagger/index.d.ts:23


swaggerCSP

swaggerCSP: any

Overrides

FastifyInstance.swaggerCSP

Defined in

src/types.ts:9


validatorCompiler

validatorCompiler: undefined | FastifySchemaCompiler<any>

Fastify schema validator for all routes.

Inherited from

FastifyInstance.validatorCompiler

Defined in

node_modules/fastify/types/instance.d.ts:508


version

version: string

Inherited from

FastifyInstance.version

Defined in

node_modules/fastify/types/instance.d.ts:129

Methods

[asyncDispose]

[asyncDispose](): Promise<undefined>

Alias for ()

Returns

Promise<undefined>

Inherited from

FastifyInstance.[asyncDispose]

Defined in

node_modules/fastify/types/instance.d.ts:148


addConstraintStrategy

addConstraintStrategy(strategy): void

Parameters

NameType
strategyConstraintStrategy<V1, unknown>

Returns

void

Inherited from

FastifyInstance.addConstraintStrategy

Defined in

node_modules/fastify/types/instance.d.ts:160


addHook

addHook<RouteGeneric, ContextConfig, SchemaCompiler, Logger, Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

onRequest is the first hook to be executed in the request lifecycle. There was no previous hook, the next hook will be preParsing. Notice: in the onRequest hook, request.body will always be null, because the body parsing happens before the preHandler hook.

Type parameters

NameType
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigunknown
SchemaCompilerextends FastifySchema = FastifySchema
Loggerextends FastifyBaseLogger = FastifyBaseLogger
Fnextends onRequestHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> | onRequestAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> = onRequestHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger>

Parameters

NameType
name"onRequest"
hookFn extends unknown ? Fn extends AsyncFunction ? onRequestAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : onRequestHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:230

addHook<RouteGeneric, ContextConfig, SchemaCompiler, Logger, Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

preParsing is the second hook to be executed in the request lifecycle. The previous hook was onRequest, the next hook will be preValidation. Notice: in the preParsing hook, request.body will always be null, because the body parsing happens before the preHandler hook.

Type parameters

NameType
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigunknown
SchemaCompilerextends FastifySchema = FastifySchema
Loggerextends FastifyBaseLogger = FastifyBaseLogger
Fnextends preParsingHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> | preParsingAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> = preParsingHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger>

Parameters

NameType
name"preParsing"
hookFn extends unknown ? Fn extends AsyncFunction ? preParsingAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : preParsingHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:245

addHook<RouteGeneric, ContextConfig, SchemaCompiler, Logger, Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

preValidation is the third hook to be executed in the request lifecycle. The previous hook was preParsing, the next hook will be preHandler.

Type parameters

NameType
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigunknown
SchemaCompilerextends FastifySchema = FastifySchema
Loggerextends FastifyBaseLogger = FastifyBaseLogger
Fnextends preValidationHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> | preValidationAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> = preValidationHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger>

Parameters

NameType
name"preValidation"
hookFn extends unknown ? Fn extends AsyncFunction ? preValidationAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : preValidationHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:259

addHook<RouteGeneric, ContextConfig, SchemaCompiler, Logger, Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

preHandler is the fourth hook to be executed in the request lifecycle. The previous hook was preValidation, the next hook will be preSerialization.

Type parameters

NameType
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigunknown
SchemaCompilerextends FastifySchema = FastifySchema
Loggerextends FastifyBaseLogger = FastifyBaseLogger
Fnextends preHandlerHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> | preHandlerAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> = preHandlerHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger>

Parameters

NameType
name"preHandler"
hookFn extends unknown ? Fn extends AsyncFunction ? preHandlerAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : preHandlerHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:273

addHook<PreSerializationPayload, RouteGeneric, ContextConfig, SchemaCompiler, Logger, Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

preSerialization is the fifth hook to be executed in the request lifecycle. The previous hook was preHandler, the next hook will be onSend. Note: the hook is NOT called if the payload is a string, a Buffer, a stream or null.

Type parameters

NameType
PreSerializationPayloadunknown
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigunknown
SchemaCompilerextends FastifySchema = FastifySchema
Loggerextends FastifyBaseLogger = FastifyBaseLogger
Fnextends preSerializationHookHandler<PreSerializationPayload, RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> | preSerializationAsyncHookHandler<PreSerializationPayload, RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> = preSerializationHookHandler<PreSerializationPayload, RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger>

Parameters

NameType
name"preSerialization"
hookFn extends unknown ? Fn extends AsyncFunction ? preSerializationAsyncHookHandler<PreSerializationPayload, RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : preSerializationHookHandler<PreSerializationPayload, RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:288

addHook<OnSendPayload, RouteGeneric, ContextConfig, SchemaCompiler, Logger, Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

You can change the payload with the onSend hook. It is the sixth hook to be executed in the request lifecycle. The previous hook was preSerialization, the next hook will be onResponse. Note: If you change the payload, you may only change it to a string, a Buffer, a stream, or null.

Type parameters

NameType
OnSendPayloadunknown
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigunknown
SchemaCompilerextends FastifySchema = FastifySchema
Loggerextends FastifyBaseLogger = FastifyBaseLogger
Fnextends onSendHookHandler<OnSendPayload, RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> | onSendAsyncHookHandler<OnSendPayload, RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> = onSendHookHandler<OnSendPayload, RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger>

Parameters

NameType
name"onSend"
hookFn extends unknown ? Fn extends AsyncFunction ? onSendAsyncHookHandler<OnSendPayload, RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : onSendHookHandler<OnSendPayload, RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:304

addHook<RouteGeneric, ContextConfig, SchemaCompiler, Logger, Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

onResponse is the seventh and last hook in the request hook lifecycle. The previous hook was onSend, there is no next hook. The onResponse hook is executed when a response has been sent, so you will not be able to send more data to the client. It can however be useful for sending data to external services, for example to gather statistics.

Type parameters

NameType
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigunknown
SchemaCompilerextends FastifySchema = FastifySchema
Loggerextends FastifyBaseLogger = FastifyBaseLogger
Fnextends onResponseHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> | onResponseAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> = onResponseHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger>

Parameters

NameType
name"onResponse"
hookFn extends unknown ? Fn extends AsyncFunction ? onResponseAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : onResponseHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:320

addHook<RouteGeneric, ContextConfig, SchemaCompiler, Logger, Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

onTimeout is useful if you need to monitor the request timed out in your service. (if the connectionTimeout property is set on the fastify instance) The onTimeout hook is executed when a request is timed out and the http socket has been hanged up. Therefore you will not be able to send data to the client.

Type parameters

NameType
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigunknown
SchemaCompilerextends FastifySchema = FastifySchema
Loggerextends FastifyBaseLogger = FastifyBaseLogger
Fnextends onTimeoutHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> | onTimeoutAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> = onTimeoutHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger>

Parameters

NameType
name"onTimeout"
hookFn extends unknown ? Fn extends AsyncFunction ? onTimeoutAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : onTimeoutHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:335

addHook<RouteGeneric, ContextConfig, SchemaCompiler, Logger, Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

onRequestAbort is useful if you need to monitor the if the client aborts the request (if the request.raw.aborted property is set to true). The onRequestAbort hook is executed when a client closes the connection before the entire request has been received. Therefore, you will not be able to send data to the client. Notice: client abort detection is not completely reliable. See: https://github.com/fastify/fastify/blob/main/docs/Guides/Detecting-When-Clients-Abort.md

Type parameters

NameType
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigunknown
SchemaCompilerextends FastifySchema = FastifySchema
Loggerextends FastifyBaseLogger = FastifyBaseLogger
Fnextends onRequestAbortHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> | onRequestAbortAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> = onRequestAbortHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger>

Parameters

NameType
name"onRequestAbort"
hookFn extends unknown ? Fn extends AsyncFunction ? onRequestAbortAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : onRequestAbortHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:351

addHook<RouteGeneric, ContextConfig, SchemaCompiler, Logger, Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

This hook is useful if you need to do some custom error logging or add some specific header in case of error. It is not intended for changing the error, and calling reply.send will throw an exception. This hook will be executed only after the customErrorHandler has been executed, and only if the customErrorHandler sends an error back to the user (Note that the default customErrorHandler always sends the error back to the user). Notice: unlike the other hooks, pass an error to the done function is not supported.

Type parameters

NameType
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigunknown
SchemaCompilerextends FastifySchema = FastifySchema
Loggerextends FastifyBaseLogger = FastifyBaseLogger
Fnextends onErrorHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, FastifyError, SchemaCompiler, FastifyTypeProviderDefault, Logger> | onErrorAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, FastifyError, SchemaCompiler, FastifyTypeProviderDefault, Logger> = onErrorHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, FastifyError, SchemaCompiler, FastifyTypeProviderDefault, Logger>

Parameters

NameType
name"onError"
hookFn extends unknown ? Fn extends AsyncFunction ? onErrorAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, FastifyError, SchemaCompiler, FastifyTypeProviderDefault, Logger> : onErrorHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, FastifyError, SchemaCompiler, FastifyTypeProviderDefault, Logger> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:368

addHook<RouteGeneric, ContextConfig, SchemaCompiler, Logger>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

Triggered when a new route is registered. Listeners are passed a routeOptions object as the sole parameter. The interface is synchronous, and, as such, the listener does not get passed a callback

Type parameters

NameType
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigunknown
SchemaCompilerextends FastifySchema = FastifySchema
Loggerextends FastifyBaseLogger = FastifyBaseLogger

Parameters

NameType
name"onRoute"
hookonRouteHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, Logger>

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Logger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:384

addHook(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Triggered when a new plugin is registered and a new encapsulation context is created. The hook will be executed before the registered code. This hook can be useful if you are developing a plugin that needs to know when a plugin context is formed, and you want to operate in that specific context. Note: This hook will not be called if a plugin is wrapped inside fastify-plugin.

Parameters

NameType
name"onRegister"
hookonRegisterHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault, FastifyPluginOptions>

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:399

addHook<Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Triggered when fastify.listen() or fastify.ready() is invoked to start the server. It is useful when plugins need a "ready" event, for example to load data before the server start listening for requests.

Type parameters

NameType
Fnextends onReadyHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> | onReadyAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> = onReadyHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Parameters

NameType
name"onReady"
hookFn extends unknown ? Fn extends AsyncFunction ? onReadyAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> : onReadyHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:407

addHook<Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Triggered when fastify.listen() is invoked to start the server. It is useful when plugins need a "onListen" event, for example to run logics after the server start listening for requests.

Type parameters

NameType
Fnextends onListenAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> | onListenHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> = onListenHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Parameters

NameType
name"onListen"
hookFn extends unknown ? Fn extends AsyncFunction ? onListenAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> : onListenHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:417

addHook<Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Triggered when fastify.close() is invoked to stop the server. It is useful when plugins need a "shutdown" event, for example to close an open connection to a database.

Type parameters

NameType
Fnextends onCloseHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> | onCloseAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> = onCloseHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Parameters

NameType
name"onClose"
hookFn extends unknown ? Fn extends AsyncFunction ? onCloseAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> : onCloseHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:427

addHook<Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Triggered when fastify.close() is invoked to stop the server. It is useful when plugins need to cancel some state to allow the server to close successfully.

Type parameters

NameType
Fnextends preCloseHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> | preCloseAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> = preCloseHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Parameters

NameType
name"preClose"
hookFn extends unknown ? Fn extends AsyncFunction ? preCloseAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> : preCloseHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:437

addHook<K, Fn>(name, hook): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Type parameters

NameType
Kextends ApplicationHook | LifecycleHook
Fnextends (...args: any) => any

Parameters

NameType
nameK
hookFn extends unknown ? Fn extends AsyncFunction ? HookAsyncLookup<K> : HookLookup<K> : Fn

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addHook

Defined in

node_modules/fastify/types/instance.d.ts:444


addSchema

addSchema(schema): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Parameters

NameType
schemaunknown

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.addSchema

Defined in

node_modules/fastify/types/instance.d.ts:135


addresses

addresses(): AddressInfo[]

Returns

AddressInfo[]

Inherited from

FastifyInstance.addresses

Defined in

node_modules/fastify/types/instance.d.ts:132


after

after(): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> & PromiseLike<undefined>

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> & PromiseLike<undefined>

Inherited from

FastifyInstance.after

Defined in

node_modules/fastify/types/instance.d.ts:139

after(afterListener): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Parameters

NameType
afterListener(err: Error) => void

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.after

Defined in

node_modules/fastify/types/instance.d.ts:140


close

close(): Promise<undefined>

Returns

Promise<undefined>

Inherited from

FastifyInstance.close

Defined in

node_modules/fastify/types/instance.d.ts:142

close(closeListener): undefined

Parameters

NameType
closeListener() => void

Returns

undefined

Inherited from

FastifyInstance.close

Defined in

node_modules/fastify/types/instance.d.ts:143


getDefaultRoute

getDefaultRoute(): DefaultRoute<IncomingMessage, ServerResponse<IncomingMessage>>

Returns

DefaultRoute<IncomingMessage, ServerResponse<IncomingMessage>>

Inherited from

FastifyInstance.getDefaultRoute

Defined in

node_modules/fastify/types/instance.d.ts:198


getSchema

getSchema(schemaId): unknown

Parameters

NameType
schemaIdstring

Returns

unknown

Inherited from

FastifyInstance.getSchema

Defined in

node_modules/fastify/types/instance.d.ts:136


getSchemas

getSchemas(): Record<string, unknown>

Returns

Record<string, unknown>

Inherited from

FastifyInstance.getSchemas

Defined in

node_modules/fastify/types/instance.d.ts:137


hasConstraintStrategy

hasConstraintStrategy(strategyName): boolean

Parameters

NameType
strategyNamestring

Returns

boolean

Inherited from

FastifyInstance.hasConstraintStrategy

Defined in

node_modules/fastify/types/instance.d.ts:161


hasDecorator

hasDecorator(decorator): boolean

Parameters

NameType
decoratorstring | symbol

Returns

boolean

Inherited from

FastifyInstance.hasDecorator

Defined in

node_modules/fastify/types/instance.d.ts:155


hasPlugin

hasPlugin(name): boolean

Parameters

NameType
namestring

Returns

boolean

Inherited from

FastifyInstance.hasPlugin

Defined in

node_modules/fastify/types/instance.d.ts:158


hasReplyDecorator

hasReplyDecorator(decorator): boolean

Parameters

NameType
decoratorstring | symbol

Returns

boolean

Inherited from

FastifyInstance.hasReplyDecorator

Defined in

node_modules/fastify/types/instance.d.ts:157


hasRequestDecorator

hasRequestDecorator(decorator): boolean

Parameters

NameType
decoratorstring | symbol

Returns

boolean

Inherited from

FastifyInstance.hasRequestDecorator

Defined in

node_modules/fastify/types/instance.d.ts:156


hasRoute

hasRoute<RouteGeneric, ContextConfig, SchemaCompiler>(opts): boolean

Type parameters

NameType
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigunknown
SchemaCompilerextends FastifySchema = FastifySchema

Parameters

NameType
optsPick<RouteOptions<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, FastifyBaseLogger>, "url" | "method" | "constraints">

Returns

boolean

Inherited from

FastifyInstance.hasRoute

Defined in

node_modules/fastify/types/instance.d.ts:216


inject

inject(opts, cb): void

Parameters

NameType
optsstring | InjectOptions
cbCallbackFunc

Returns

void

Inherited from

FastifyInstance.inject

Defined in

node_modules/fastify/types/instance.d.ts:163

inject(opts): Promise<Response>

Parameters

NameType
optsstring | InjectOptions

Returns

Promise<Response>

Inherited from

FastifyInstance.inject

Defined in

node_modules/fastify/types/instance.d.ts:164

inject(): Chain

Returns

Chain

Inherited from

FastifyInstance.inject

Defined in

node_modules/fastify/types/instance.d.ts:165


listen

listen(opts, callback): void

Parameters

NameType
optsFastifyListenOptions
callback(err: null | Error, address: string) => void

Returns

void

Inherited from

FastifyInstance.listen

Defined in

node_modules/fastify/types/instance.d.ts:167

listen(opts?): Promise<string>

Parameters

NameType
opts?FastifyListenOptions

Returns

Promise<string>

Inherited from

FastifyInstance.listen

Defined in

node_modules/fastify/types/instance.d.ts:168

listen(callback): void

Parameters

NameType
callback(err: null | Error, address: string) => void

Returns

void

Inherited from

FastifyInstance.listen

Defined in

node_modules/fastify/types/instance.d.ts:169

listen(port, address, backlog, callback): void

Parameters

NameType
portstring | number
addressstring
backlognumber
callback(err: null | Error, address: string) => void

Returns

void

Deprecated

Variadic listen method is deprecated. Please use .listen(optionsObject, callback) instead. The variadic signature will be removed in fastify@5

See

https://github.com/fastify/fastify/pull/3712

Inherited from

FastifyInstance.listen

Defined in

node_modules/fastify/types/instance.d.ts:175

listen(port, address, callback): void

Parameters

NameType
portstring | number
addressstring
callback(err: null | Error, address: string) => void

Returns

void

Deprecated

Variadic listen method is deprecated. Please use .listen(optionsObject, callback) instead. The variadic signature will be removed in fastify@5

See

https://github.com/fastify/fastify/pull/3712

Inherited from

FastifyInstance.listen

Defined in

node_modules/fastify/types/instance.d.ts:180

listen(port, callback): void

Parameters

NameType
portstring | number
callback(err: null | Error, address: string) => void

Returns

void

Deprecated

Variadic listen method is deprecated. Please use .listen(optionsObject, callback) instead. The variadic signature will be removed in fastify@5

See

https://github.com/fastify/fastify/pull/3712

Inherited from

FastifyInstance.listen

Defined in

node_modules/fastify/types/instance.d.ts:185

listen(port, address?, backlog?): Promise<string>

Parameters

NameType
portstring | number
address?string
backlog?number

Returns

Promise<string>

Deprecated

Variadic listen method is deprecated. Please use .listen(optionsObject) instead. The variadic signature will be removed in fastify@5

See

https://github.com/fastify/fastify/pull/3712

Inherited from

FastifyInstance.listen

Defined in

node_modules/fastify/types/instance.d.ts:190


parseCookie

parseCookie(cookieHeader): Object

Manual cookie parsing method

Parameters

NameTypeDescription
cookieHeaderstringRaw cookie header value

Returns

Object

Docs

https://github.com/fastify/fastify-cookie#manual-cookie-parsing

Inherited from

FastifyInstance.parseCookie

Defined in

node_modules/@fastify/cookie/types/plugin.d.ts:21


printPlugins

printPlugins(): string

Prints the representation of the plugin tree used by avvio, the plugin registration system

Returns

string

Inherited from

FastifyInstance.printPlugins

Defined in

node_modules/fastify/types/instance.d.ts:569


printRoutes

printRoutes(opts?): string

Prints the representation of the internal radix tree used by the router

Parameters

NameType
opts?PrintRoutesOptions

Returns

string

Inherited from

FastifyInstance.printRoutes

Defined in

node_modules/fastify/types/instance.d.ts:564


ready

ready(): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> & PromiseLike<undefined>

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> & PromiseLike<undefined>

Inherited from

FastifyInstance.ready

Defined in

node_modules/fastify/types/instance.d.ts:192

ready(readyListener): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Parameters

NameType
readyListener(err: Error) => void

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.ready

Defined in

node_modules/fastify/types/instance.d.ts:193


route

route<RouteGeneric, ContextConfig, SchemaCompiler>(opts): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Type parameters

NameType
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigunknown
SchemaCompilerextends FastifySchema = FastifySchema

Parameters

NameType
optsRouteOptions<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, FastifyTypeProviderDefault, FastifyBaseLogger>

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.route

Defined in

node_modules/fastify/types/instance.d.ts:201


routing

routing(req, res): void

Parameters

NameType
reqIncomingMessage
resServerResponse<IncomingMessage>

Returns

void

Inherited from

FastifyInstance.routing

Defined in

node_modules/fastify/types/instance.d.ts:197


serializeCookie

serializeCookie(name, value, opts?): string

Serialize a cookie name-value pair into a Set-Cookie header string

Parameters

NameTypeDescription
namestringCookie name
valuestringCookie value
opts?SerializeOptionsOptions

Returns

string

Throws

When maxAge option is invalid

Inherited from

FastifyInstance.serializeCookie

Defined in

node_modules/@fastify/cookie/types/plugin.d.ts:14


setChildLoggerFactory

setChildLoggerFactory(factory): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Hook function that is called when creating a child logger instance for each request which allows for modifying or adding child logger bindings and logger options, or returning a completely custom child logger implementation.

Child logger bindings have a performance advantage over per-log bindings, because they are pre-serialised by Pino when the child logger is created.

For example:

function childLoggerFactory(logger, bindings, opts, rawReq) {
// Calculate additional bindings from the request
bindings.traceContext = rawReq.headers['x-cloud-trace-context']
return logger.child(bindings, opts);
}

Parameters

NameType
factoryFastifyChildLoggerFactory<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.setChildLoggerFactory

Defined in

node_modules/fastify/types/instance.d.ts:503


setDefaultRoute

setDefaultRoute(defaultRoute): void

Parameters

NameType
defaultRouteDefaultRoute<IncomingMessage, ServerResponse<IncomingMessage>>

Returns

void

Inherited from

FastifyInstance.setDefaultRoute

Defined in

node_modules/fastify/types/instance.d.ts:199


setErrorHandler

setErrorHandler<TError, RouteGeneric, SchemaCompiler, TypeProvider>(handler): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, TypeProvider>

Set a function that will be called whenever an error happens

Type parameters

NameType
TErrorextends Error = FastifyError
RouteGenericextends RouteGenericInterface = RouteGenericInterface
SchemaCompilerextends FastifySchema = FastifySchema
TypeProviderextends FastifyTypeProvider = FastifyTypeProviderDefault

Parameters

NameType
handler(this: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, TypeProvider>, error: TError, request: FastifyRequest<RouteGeneric, RawServerDefault, IncomingMessage, SchemaCompiler, TypeProvider, unknown, FastifyBaseLogger, ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>>, reply: FastifyReply<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, unknown, SchemaCompiler, TypeProvider, UndefinedToUnknown<KeysOf<RouteGeneric["Reply"]> extends never ? ResolveReplyFromSchemaCompiler<TypeProvider, SchemaCompiler> : RouteGeneric["Reply"]>>) => any

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, TypeProvider>

Inherited from

FastifyInstance.setErrorHandler

Defined in

node_modules/fastify/types/instance.d.ts:475


setNotFoundHandler

setNotFoundHandler<RouteGeneric, ContextConfig, TypeProvider, SchemaCompiler>(handler): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, TypeProvider>

Set the 404 handler

Type parameters

NameType
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigextends unknown = unknown
TypeProviderextends FastifyTypeProvider = FastifyTypeProviderDefault
SchemaCompilerextends FastifySchema = FastifySchema

Parameters

NameType
handlerRouteHandlerMethod<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, FastifyBaseLogger>

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, TypeProvider>

Inherited from

FastifyInstance.setNotFoundHandler

Defined in

node_modules/fastify/types/instance.d.ts:455

setNotFoundHandler<RouteGeneric, ContextConfig, TypeProvider, SchemaCompiler>(opts, handler): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, TypeProvider>

Type parameters

NameType
RouteGenericextends RouteGenericInterface = RouteGenericInterface
ContextConfigextends unknown = unknown
TypeProviderextends FastifyTypeProvider = FastifyTypeProviderDefault
SchemaCompilerextends FastifySchema = FastifySchema

Parameters

NameType
optsObject
opts.preHandler?preHandlerHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, FastifyBaseLogger> | preHandlerHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, FastifyBaseLogger>[]
opts.preValidation?preValidationHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, FastifyBaseLogger> | preValidationHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, FastifyBaseLogger>[]
handlerRouteHandlerMethod<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, FastifyBaseLogger>

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, TypeProvider>

Inherited from

FastifyInstance.setNotFoundHandler

Defined in

node_modules/fastify/types/instance.d.ts:459


setReplySerializer

setReplySerializer(replySerializer): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Set the reply serializer for all routes.

Parameters

NameType
replySerializer(payload: unknown, statusCode: number) => string

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.setReplySerializer

Defined in

node_modules/fastify/types/instance.d.ts:533


setSchemaController

setSchemaController(schemaControllerOpts): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Set the schema controller for all routes.

Parameters

NameType
schemaControllerOptsFastifySchemaControllerOptions

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.setSchemaController

Defined in

node_modules/fastify/types/instance.d.ts:528


setSchemaErrorFormatter

setSchemaErrorFormatter(errorFormatter): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Parameters

NameType
errorFormatterSchemaErrorFormatter

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.setSchemaErrorFormatter

Defined in

node_modules/fastify/types/instance.d.ts:538


setSerializerCompiler

setSerializerCompiler<T>(schemaCompiler): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Set the schema serializer for all routes.

Type parameters

NameType
TFastifySchema

Parameters

NameType
schemaCompilerFastifySerializerCompiler<T>

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.setSerializerCompiler

Defined in

node_modules/fastify/types/instance.d.ts:523


setValidatorCompiler

setValidatorCompiler<T>(schemaCompiler): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Set the schema validator for all routes.

Type parameters

NameType
TFastifySchema

Parameters

NameType
schemaCompilerFastifySchemaCompiler<T>

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Inherited from

FastifyInstance.setValidatorCompiler

Defined in

node_modules/fastify/types/instance.d.ts:513


signCookie

signCookie(value): string

Signs the specified cookie using the secret/signer provided.

Parameters

NameTypeDescription
valuestringcookie value

Returns

string

Inherited from

FastifyInstance.signCookie

Defined in

node_modules/@fastify/cookie/types/plugin.d.ts:45


unsignCookie

unsignCookie(value): UnsignResult

Unsigns the specified cookie using the secret/signer provided.

Parameters

NameTypeDescription
valuestringCookie value

Returns

UnsignResult

Inherited from

FastifyInstance.unsignCookie

Defined in

node_modules/@fastify/cookie/types/plugin.d.ts:51


withTypeProvider

withTypeProvider<Provider>(): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, Provider>

Type parameters

NameType
Providerextends FastifyTypeProvider

Returns

FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, Provider>

Inherited from

FastifyInstance.withTypeProvider

Defined in

node_modules/fastify/types/instance.d.ts:133