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:554


all​

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

Inherited from​

FastifyInstance.all

Defined in​

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


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:496


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:152


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:154


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:153


defaultTextParser​

• defaultTextParser: FastifyBodyParser<string>

Fastify default plain text parser

Inherited from​

FastifyInstance.defaultTextParser

Defined in​

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


delete​

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

Inherited from​

FastifyInstance.delete

Defined in​

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


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:477


get​

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

Inherited from​

FastifyInstance.get

Defined in​

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


getDefaultJsonParser​

• getDefaultJsonParser: getDefaultJsonParser

Fastify default JSON parser

Inherited from​

FastifyInstance.getDefaultJsonParser

Defined in​

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


hasContentTypeParser​

• hasContentTypeParser: hasContentTypeParser

Inherited from​

FastifyInstance.hasContentTypeParser

Defined in​

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


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

Inherited from​

FastifyInstance.head

Defined in​

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


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 ; useSemicolonDelimiter?: boolean }>

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:586


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:132


log​

• log: FastifyBaseLogger

Inherited from​

FastifyInstance.log

Defined in​

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


metrics​

• metrics: IFastifyMetrics

Metrics interface

Inherited from​

FastifyInstance.metrics

Defined in​

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


multipartErrors​

• multipartErrors: MultipartErrors

Inherited from​

FastifyInstance.multipartErrors

Defined in​

node_modules/@fastify/multipart/types/index.d.ts:34


options​

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

Inherited from​

FastifyInstance.options

Defined in​

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


patch​

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

Inherited from​

FastifyInstance.patch

Defined in​

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


pluginName​

• pluginName: string

Inherited from​

FastifyInstance.pluginName

Defined in​

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


post​

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

Inherited from​

FastifyInstance.post

Defined in​

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


prefix​

• prefix: string

Inherited from​

FastifyInstance.prefix

Defined in​

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


put​

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

Inherited from​

FastifyInstance.put

Defined in​

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


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:196


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:563


removeContentTypeParser​

• removeContentTypeParser: removeContentTypeParser

Remove an existing content type parser

Inherited from​

FastifyInstance.removeContentTypeParser

Defined in​

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


serializerCompiler​

• serializerCompiler: undefined | FastifySerializerCompiler<any>

Fastify schema serializer for all routes.

Inherited from​

FastifyInstance.serializerCompiler

Defined in​

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


server​

• server: RawServerDefault

Inherited from​

FastifyInstance.server

Defined in​

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


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:520


version​

• version: string

Inherited from​

FastifyInstance.version

Defined in​

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

Methods​

[asyncDispose]​

▸ [asyncDispose](): Promise<undefined>

Alias for ()

Returns​

Promise<undefined>

Inherited from​

FastifyInstance.[asyncDispose]

Defined in​

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


addConstraintStrategy​

▸ addConstraintStrategy(strategy): void

Parameters​

NameType
strategyConstraintStrategy<V1, unknown>

Returns​

void

Inherited from​

FastifyInstance.addConstraintStrategy

Defined in​

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


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:237

▸ 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:252

▸ 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:266

▸ 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:280

▸ 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:295

▸ 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:311

▸ 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:327

▸ 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:342

▸ 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:358

▸ 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:375

▸ 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:391

▸ 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:406

▸ 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:414

▸ 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:424

▸ 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:434

▸ 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:444

▸ 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:451


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:136


addresses​

▸ addresses(): AddressInfo[]

Returns​

AddressInfo[]

Inherited from​

FastifyInstance.addresses

Defined in​

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


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:140

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

Parameters​

NameType
afterListener(err: null | Error) => void

Returns​

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

Inherited from​

FastifyInstance.after

Defined in​

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


close​

▸ close(): Promise<undefined>

Returns​

Promise<undefined>

Inherited from​

FastifyInstance.close

Defined in​

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

▸ close(closeListener): undefined

Parameters​

NameType
closeListener() => void

Returns​

undefined

Inherited from​

FastifyInstance.close

Defined in​

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


findRoute​

▸ findRoute<RouteGeneric, ContextConfig, SchemaCompiler>(opts): Omit<FindMyWayFindResult<RawServerDefault>, "store">

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​

Omit<FindMyWayFindResult<RawServerDefault>, "store">

Inherited from​

FastifyInstance.findRoute

Defined in​

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


getDefaultRoute​

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

Returns​

DefaultRoute<IncomingMessage, ServerResponse<IncomingMessage>>

Inherited from​

FastifyInstance.getDefaultRoute

Defined in​

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


getSchema​

▸ getSchema(schemaId): unknown

Parameters​

NameType
schemaIdstring

Returns​

unknown

Inherited from​

FastifyInstance.getSchema

Defined in​

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


getSchemas​

▸ getSchemas(): Record<string, unknown>

Returns​

Record<string, unknown>

Inherited from​

FastifyInstance.getSchemas

Defined in​

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


hasConstraintStrategy​

▸ hasConstraintStrategy(strategyName): boolean

Parameters​

NameType
strategyNamestring

Returns​

boolean

Inherited from​

FastifyInstance.hasConstraintStrategy

Defined in​

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


hasDecorator​

▸ hasDecorator(decorator): boolean

Parameters​

NameType
decoratorstring | symbol

Returns​

boolean

Inherited from​

FastifyInstance.hasDecorator

Defined in​

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


hasPlugin​

▸ hasPlugin(name): boolean

Parameters​

NameType
namestring

Returns​

boolean

Inherited from​

FastifyInstance.hasPlugin

Defined in​

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


hasReplyDecorator​

▸ hasReplyDecorator(decorator): boolean

Parameters​

NameType
decoratorstring | symbol

Returns​

boolean

Inherited from​

FastifyInstance.hasReplyDecorator

Defined in​

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


hasRequestDecorator​

▸ hasRequestDecorator(decorator): boolean

Parameters​

NameType
decoratorstring | symbol

Returns​

boolean

Inherited from​

FastifyInstance.hasRequestDecorator

Defined in​

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


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:217


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:164

▸ inject(opts): Promise<Response>

Parameters​

NameType
optsstring | InjectOptions

Returns​

Promise<Response>

Inherited from​

FastifyInstance.inject

Defined in​

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

▸ inject(): Chain

Returns​

Chain

Inherited from​

FastifyInstance.inject

Defined in​

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


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:168

▸ listen(opts?): Promise<string>

Parameters​

NameType
opts?FastifyListenOptions

Returns​

Promise<string>

Inherited from​

FastifyInstance.listen

Defined in​

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

▸ 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:170

▸ 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:176

▸ 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:181

▸ 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:186

▸ 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:191


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:581


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:576


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:193

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

Parameters​

NameType
readyListener(err: null | Error) => void

Returns​

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

Inherited from​

FastifyInstance.ready

Defined in​

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


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:202


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:198


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:515


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:200


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:482


setGenReqId​

▸ setGenReqId(fn): FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Set a function that will generate a request-ids

Parameters​

NameType
fn(req: IncomingMessage) => string

Returns​

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

Inherited from​

FastifyInstance.setGenReqId

Defined in​

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


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:462

▸ 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> | preHandlerAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, FastifyBaseLogger> | preHandlerHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, FastifyBaseLogger>[] | preHandlerAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, FastifyBaseLogger>[]
opts.preValidation?preValidationHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, FastifyBaseLogger> | preValidationAsyncHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, FastifyBaseLogger> | preValidationHookHandler<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, FastifyBaseLogger>[] | preValidationAsyncHookHandler<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:466


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:545


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:540


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:550


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:535


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:525


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:134