import { RawReplyDefaultExpression, RawServerBase, RawServerDefault, ContextConfigDefault, RawRequestDefaultExpression, ReplyDefault } from './utils' import { FastifyContext } from './context' import { FastifyLoggerInstance } from './logger' import { FastifyRequest } from './request' import { RouteGenericInterface } from './route' export interface ReplyGenericInterface { Reply?: ReplyDefault; } /** * 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. */ export interface FastifyReply< RawServer extends RawServerBase = RawServerDefault, RawRequest extends RawRequestDefaultExpression = RawRequestDefaultExpression, RawReply extends RawReplyDefaultExpression = RawReplyDefaultExpression, RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, > { raw: RawReply; context: FastifyContext; log: FastifyLoggerInstance; request: FastifyRequest; code(statusCode: number): FastifyReply; status(statusCode: number): FastifyReply; statusCode: number; sent: boolean; send(payload?: T): FastifyReply; header(key: string, value: any): FastifyReply; headers(values: {[key: string]: any}): FastifyReply; getHeader(key: string): string | undefined; getHeaders(): { // Node's `getHeaders()` can return numbers and arrays, so they're included here as possible types. [key: string]: number | string | string[] | undefined; }; removeHeader(key: string): void; hasHeader(key: string): boolean; // Note: should consider refactoring the argument order for redirect. statusCode is optional so it should be after the required url param redirect(statusCode: number, url: string): FastifyReply; redirect(url: string): FastifyReply; callNotFound(): void; getResponseTime(): number; type(contentType: string): FastifyReply; serializer(fn: (payload: any) => string): FastifyReply; serialize(payload: any): string; then(fullfilled: () => void, rejected: (err: Error) => void): void; }