Interface FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, ReplyType>

FastifyReply is an instance of the standard http or http2 reply types. It defaults to http.ServerResponse, and it also extends the relative reply object.

interface FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, ReplyType> {
    context: FastifyReplyContext<ContextConfig>;
    elapsedTime: number;
    log: FastifyBaseLogger;
    raw: RawReply;
    request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, unknown, FastifyBaseLogger, ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>>;
    sent: boolean;
    server: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>;
    statusCode: number;
    trailer: ((key, fn) => FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, UndefinedToUnknown<KeysOf<RouteGeneric["Reply"]> extends never
        ? ResolveReplyFromSchemaCompiler<TypeProvider, SchemaCompiler>
        : RouteGeneric["Reply"]>>);
    callNotFound(): void;
    code<Code>(statusCode): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, ResolveReplyTypeWithRouteGeneric<RouteGeneric["Reply"], Code, SchemaCompiler, TypeProvider>>;
    compileSerializationSchema(schema, httpStatus?, contentType?): ((payload) => string);
    getHeader(key): undefined | string | number | string[];
    getHeaders(): Record<HttpHeader, undefined | string | number | string[]>;
    getResponseTime(): number;
    getSerializationFunction(httpStatus, contentType?): undefined | ((payload) => string);
    getSerializationFunction(schema): undefined | ((payload) => string);
    hasHeader(key): boolean;
    hasTrailer(key): boolean;
    header(key, value): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, UndefinedToUnknown<KeysOf<RouteGeneric["Reply"]> extends never
        ? ResolveReplyFromSchemaCompiler<TypeProvider, SchemaCompiler>
        : RouteGeneric["Reply"]>>;
    headers(values): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, UndefinedToUnknown<KeysOf<RouteGeneric["Reply"]> extends never
        ? ResolveReplyFromSchemaCompiler<TypeProvider, SchemaCompiler>
        : RouteGeneric["Reply"]>>;
    hijack(): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, UndefinedToUnknown<KeysOf<RouteGeneric["Reply"]> extends never
        ? ResolveReplyFromSchemaCompiler<TypeProvider, SchemaCompiler>
        : RouteGeneric["Reply"]>>;
    redirect(statusCode, url): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, UndefinedToUnknown<KeysOf<RouteGeneric["Reply"]> extends never
        ? ResolveReplyFromSchemaCompiler<TypeProvider, SchemaCompiler>
        : RouteGeneric["Reply"]>>;
    redirect(url): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, UndefinedToUnknown<KeysOf<RouteGeneric["Reply"]> extends never
        ? ResolveReplyFromSchemaCompiler<TypeProvider, SchemaCompiler>
        : RouteGeneric["Reply"]>>;
    removeHeader(key): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, UndefinedToUnknown<KeysOf<RouteGeneric["Reply"]> extends never
        ? ResolveReplyFromSchemaCompiler<TypeProvider, SchemaCompiler>
        : RouteGeneric["Reply"]>>;
    removeTrailer(key): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, UndefinedToUnknown<KeysOf<RouteGeneric["Reply"]> extends never
        ? ResolveReplyFromSchemaCompiler<TypeProvider, SchemaCompiler>
        : RouteGeneric["Reply"]>>;
    send(payload?): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, UndefinedToUnknown<KeysOf<RouteGeneric["Reply"]> extends never
        ? ResolveReplyFromSchemaCompiler<TypeProvider, SchemaCompiler>
        : RouteGeneric["Reply"]>>;
    serialize(payload): string | Buffer | ArrayBuffer;
    serializeInput(input, schema, httpStatus?, contentType?): string;
    serializeInput(input, httpStatus, contentType?): unknown;
    serializer(fn): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, UndefinedToUnknown<KeysOf<RouteGeneric["Reply"]> extends never
        ? ResolveReplyFromSchemaCompiler<TypeProvider, SchemaCompiler>
        : RouteGeneric["Reply"]>>;
    status<Code>(statusCode): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, ResolveReplyTypeWithRouteGeneric<RouteGeneric["Reply"], Code, SchemaCompiler, TypeProvider>>;
    then(fulfilled, rejected): void;
    type(contentType): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, UndefinedToUnknown<KeysOf<RouteGeneric["Reply"]> extends never
        ? ResolveReplyFromSchemaCompiler<TypeProvider, SchemaCompiler>
        : RouteGeneric["Reply"]>>;
}

Type Parameters

Properties

elapsedTime: number
sent: boolean
statusCode: number

Type declaration

Methods

  • Returns void

  • Parameters

    • schema: {
          [key: string]: unknown;
      }
      • [key: string]: unknown
    • Optional httpStatus: string
    • Optional contentType: string

    Returns ((payload) => string)

      • (payload): string
      • Parameters

        • payload: {
              [key: string]: unknown;
          }
          • [key: string]: unknown

        Returns string

  • Parameters

    Returns undefined | string | number | string[]

  • Returns Record<HttpHeader, undefined | string | number | string[]>

  • Returns number

    Deprecated

    Use the Reply#elapsedTime property instead

  • Parameters

    • httpStatus: string
    • Optional contentType: string

    Returns undefined | ((payload) => string)

  • Parameters

    • schema: {
          [key: string]: unknown;
      }
      • [key: string]: unknown

    Returns undefined | ((payload) => string)

  • Parameters

    Returns boolean

  • Parameters

    • key: string

    Returns boolean

  • Parameters

    • input: {
          [key: string]: unknown;
      }
      • [key: string]: unknown
    • schema: {
          [key: string]: unknown;
      }
      • [key: string]: unknown
    • Optional httpStatus: string
    • Optional contentType: string

    Returns string

  • Parameters

    • input: {
          [key: string]: unknown;
      }
      • [key: string]: unknown
    • httpStatus: string
    • Optional contentType: string

    Returns unknown

  • Parameters

    • fulfilled: (() => void)
        • (): void
        • Returns void

    • rejected: ((err) => void)
        • (err): void
        • Parameters

          Returns void

    Returns void