@nestjs/platform-fastify
Version:
Nest - modern, fast, powerful node.js web framework (@platform-fastify)
68 lines (67 loc) • 5.82 kB
TypeScript
/// <reference types="node" />
import { RequestMethod } from '@nestjs/common';
import { CorsOptions, CorsOptionsDelegate } from '@nestjs/common/interfaces/external/cors-options.interface';
import { AbstractHttpAdapter } from '@nestjs/core/adapters/http-adapter';
import { FastifyInstance, FastifyLoggerInstance, FastifyPluginAsync, FastifyPluginCallback, FastifyPluginOptions, FastifyRegisterOptions, FastifyReply, FastifyRequest, FastifyServerOptions, RawReplyDefaultExpression, RawRequestDefaultExpression, RawServerBase, RawServerDefault, RequestGenericInterface } from 'fastify';
import * as http2 from 'http2';
import * as https from 'https';
import { Chain as LightMyRequestChain, InjectOptions, Response as LightMyRequestResponse } from 'light-my-request';
import { FastifyStaticOptions, PointOfViewOptions } from '../interfaces/external';
declare type FastifyHttp2SecureOptions<Server extends http2.Http2SecureServer, Logger extends FastifyLoggerInstance = FastifyLoggerInstance> = FastifyServerOptions<Server, Logger> & {
http2: true;
https: http2.SecureServerOptions;
};
declare type FastifyHttp2Options<Server extends http2.Http2Server, Logger extends FastifyLoggerInstance = FastifyLoggerInstance> = FastifyServerOptions<Server, Logger> & {
http2: true;
http2SessionTimeout?: number;
};
declare type FastifyHttpsOptions<Server extends https.Server, Logger extends FastifyLoggerInstance = FastifyLoggerInstance> = FastifyServerOptions<Server, Logger> & {
https: https.ServerOptions;
};
export declare class FastifyAdapter<TServer extends RawServerBase = RawServerDefault, TRawRequest extends RawRequestDefaultExpression<TServer> = RawRequestDefaultExpression<TServer>, TRawResponse extends RawReplyDefaultExpression<TServer> = RawReplyDefaultExpression<TServer>> extends AbstractHttpAdapter<TServer, FastifyRequest<RequestGenericInterface, TServer, TRawRequest>, FastifyReply<TServer, TRawRequest, TRawResponse>> {
protected readonly instance: FastifyInstance<TServer, TRawRequest, TRawResponse>;
private _isParserRegistered;
private isMiddieRegistered;
get isParserRegistered(): boolean;
constructor(instanceOrOptions?: FastifyInstance<TServer> | FastifyHttp2Options<TServer> | FastifyHttp2SecureOptions<any> | FastifyHttpsOptions<any> | FastifyServerOptions<TServer>);
init(): Promise<void>;
listen(port: string | number, callback?: () => void): void;
listen(port: string | number, hostname: string, callback?: () => void): void;
reply(response: TRawResponse | FastifyReply, body: any, statusCode?: number): FastifyReply<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, import("fastify/types/route").RouteGenericInterface, unknown>;
status(response: TRawResponse | FastifyReply, statusCode: number): TRawResponse | FastifyReply<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, import("fastify/types/route").RouteGenericInterface, unknown>;
render(response: FastifyReply & {
view: Function;
}, view: string, options: any): any;
redirect(response: FastifyReply, statusCode: number, url: string): FastifyReply<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, import("fastify/types/route").RouteGenericInterface, unknown>;
setErrorHandler(handler: Parameters<FastifyInstance<TServer, TRawRequest, TRawResponse>['setErrorHandler']>[0]): FastifyInstance<TServer, TRawRequest, TRawResponse, FastifyLoggerInstance>;
setNotFoundHandler(handler: Parameters<FastifyInstance<TServer, TRawRequest, TRawResponse>['setNotFoundHandler']>[0]): FastifyInstance<TServer, TRawRequest, TRawResponse, FastifyLoggerInstance>;
getHttpServer<T = TServer>(): T;
getInstance<T = FastifyInstance<TServer, TRawRequest, TRawResponse>>(): T;
register<Options extends FastifyPluginOptions = any>(plugin: FastifyPluginCallback<Options> | FastifyPluginAsync<Options> | Promise<{
default: FastifyPluginCallback<Options>;
}> | Promise<{
default: FastifyPluginAsync<Options>;
}>, opts?: FastifyRegisterOptions<Options>): FastifyInstance<TServer, TRawRequest, TRawResponse, FastifyLoggerInstance> & PromiseLike<undefined>;
inject(): LightMyRequestChain;
inject(opts: InjectOptions | string): Promise<LightMyRequestResponse>;
close(): Promise<undefined>;
initHttpServer(): void;
useStaticAssets(options: FastifyStaticOptions): FastifyInstance<TServer, TRawRequest, TRawResponse, FastifyLoggerInstance> & PromiseLike<undefined>;
setViewEngine(options: PointOfViewOptions | string): FastifyInstance<TServer, TRawRequest, TRawResponse, FastifyLoggerInstance> & PromiseLike<undefined>;
setHeader(response: FastifyReply, name: string, value: string): FastifyReply<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, import("fastify/types/route").RouteGenericInterface, unknown>;
getRequestHostname(request: FastifyRequest): string;
getRequestMethod(request: FastifyRequest): string;
getRequestUrl(request: FastifyRequest): string;
enableCors(options: CorsOptions | CorsOptionsDelegate<FastifyRequest<RequestGenericInterface, TServer, TRawRequest>>): void;
registerParserMiddleware(): void;
createMiddlewareFactory(requestMethod: RequestMethod): Promise<(path: string, callback: Function) => any>;
getType(): string;
protected registerWithPrefix(factory: FastifyPluginCallback<any> | FastifyPluginAsync<any> | Promise<{
default: FastifyPluginCallback<any>;
}> | Promise<{
default: FastifyPluginAsync<any>;
}>, prefix?: string): FastifyInstance<TServer, TRawRequest, TRawResponse, FastifyLoggerInstance> & PromiseLike<undefined>;
private isNativeResponse;
private registerMiddie;
}
export {};