/// /// /// import { RequestMethod, VersioningOptions } from '@nestjs/common'; import { VersionValue } from '@nestjs/common/interfaces'; import { CorsOptions, CorsOptionsDelegate } from '@nestjs/common/interfaces/external/cors-options.interface'; import { AbstractHttpAdapter } from '@nestjs/core/adapters/http-adapter'; import { FastifyBaseLogger, FastifyBodyParser, FastifyInstance, FastifyPluginAsync, FastifyPluginCallback, FastifyRegister, FastifyReply, FastifyRequest, FastifyServerOptions, RawReplyDefaultExpression, RawRequestDefaultExpression, RawServerBase, RawServerDefault, RequestGenericInterface } from 'fastify'; import * as http2 from 'http2'; import * as https from 'https'; import { InjectOptions, Chain as LightMyRequestChain, Response as LightMyRequestResponse } from 'light-my-request'; import { NestFastifyBodyParserOptions } from '../interfaces'; import { FastifyStaticOptions, FastifyViewOptions } from '../interfaces/external'; type FastifyHttp2SecureOptions = FastifyServerOptions & { http2: true; https: http2.SecureServerOptions; }; type FastifyHttp2Options = FastifyServerOptions & { http2: true; http2SessionTimeout?: number; }; type FastifyHttpsOptions = FastifyServerOptions & { https: https.ServerOptions; }; type VersionedRoute = ((req: TRequest, res: TResponse, next: Function) => Function) & { version: VersionValue; versioningOptions: VersioningOptions; }; /** * The following type assertion is valid as we enforce "middie" plugin registration * which enhances the FastifyRequest.RawRequest with the "originalUrl" property. * ref https://github.com/fastify/middie/pull/16 * ref https://github.com/fastify/fastify/pull/559 */ type FastifyRawRequest = RawRequestDefaultExpression & { originalUrl?: string; }; /** * @publicApi */ export declare class FastifyAdapter = FastifyRawRequest, TRawResponse extends RawReplyDefaultExpression = RawReplyDefaultExpression, TRequest extends FastifyRequest = FastifyRequest, TReply extends FastifyReply = FastifyReply, TInstance extends FastifyInstance = FastifyInstance> extends AbstractHttpAdapter { protected readonly instance: TInstance; private _isParserRegistered; private isMiddieRegistered; private versioningOptions; private readonly versionConstraint; get isParserRegistered(): boolean; constructor(instanceOrOptions?: TInstance | FastifyHttp2Options | FastifyHttp2SecureOptions | FastifyHttpsOptions | FastifyServerOptions); init(): Promise; listen(port: string | number, callback?: () => void): void; listen(port: string | number, hostname: string, callback?: () => void): void; get(...args: any[]): FastifyInstance; post(...args: any[]): FastifyInstance; head(...args: any[]): FastifyInstance; delete(...args: any[]): FastifyInstance; put(...args: any[]): FastifyInstance; patch(...args: any[]): FastifyInstance; options(...args: any[]): FastifyInstance; applyVersionFilter(handler: Function, version: VersionValue, versioningOptions: VersioningOptions): VersionedRoute; reply(response: TRawResponse | TReply, body: any, statusCode?: number): FastifyReply; status(response: TRawResponse | TReply, statusCode: number): TRawResponse | FastifyReply; end(response: TReply, message?: string): void; render(response: TReply & { view: Function; }, view: string, options: any): any; redirect(response: TReply, statusCode: number, url: string): FastifyReply; setErrorHandler(handler: Parameters[0]): FastifyInstance; setNotFoundHandler(handler: Function): FastifyInstance; getHttpServer(): T; getInstance(): T; register>>(plugin: TRegister['0'], opts?: TRegister['1']): FastifyInstance & PromiseLike; inject(): LightMyRequestChain; inject(opts: InjectOptions | string): Promise; close(): Promise; initHttpServer(): void; useStaticAssets(options: FastifyStaticOptions): FastifyInstance & PromiseLike; setViewEngine(options: FastifyViewOptions | string): FastifyInstance & PromiseLike; isHeadersSent(response: TReply): boolean; getHeader?(response: any, name: string): any; setHeader(response: TReply, name: string, value: string): FastifyReply; appendHeader?(response: any, name: string, value: string): void; getRequestHostname(request: TRequest): string; getRequestMethod(request: TRequest): string; getRequestUrl(request: TRequest): string; getRequestUrl(request: TRawRequest): string; enableCors(options: CorsOptions | CorsOptionsDelegate): void; registerParserMiddleware(prefix?: string, rawBody?: boolean): void; useBodyParser(type: string | string[] | RegExp, rawBody: boolean, options?: NestFastifyBodyParserOptions, parser?: FastifyBodyParser): void; createMiddlewareFactory(requestMethod: RequestMethod): Promise<(path: string, callback: Function) => any>; getType(): string; protected registerWithPrefix(factory: FastifyPluginCallback | FastifyPluginAsync | Promise<{ default: FastifyPluginCallback; }> | Promise<{ default: FastifyPluginAsync; }>, prefix?: string): FastifyInstance & PromiseLike; private isNativeResponse; private registerJsonContentParser; private registerUrlencodedContentParser; private registerMiddie; private getRequestOriginalUrl; private injectRouteOptions; } export {};