Skip to content

PlatformFastify

@tsed/platform-fastify

Usage

typescript
import { PlatformFastify } from "@tsed/platform-fastify";

See /packages/platform/platform-fastify/src/types/components/PlatformFastify.ts.

Overview

ts
class PlatformFastify extends PlatformAdapter<FastifyInstance> {
    readonly NAME = "fastify";
    
    static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<TsED.Application>;
    static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<TsED.Application>>;
    mapLayers(layers: PlatformLayer[]): void;
    mapHandler(handler: (...args: any[]) => any, metadata: PlatformHandlerMetadata): (...args: any[]) => any;
    useContext(): Promise<void>;
    createApp(): {
        app: Fastify.FastifyInstance<Fastify.RawServerDefault, Http.IncomingMessage, Http.ServerResponse<Http.IncomingMessage>, Fastify.FastifyBaseLogger, Fastify.FastifyTypeProviderDefault>;
        callback: () => (request: IncomingMessage, response: ServerResponse) => Promise<void>;
    };
    afterLoadRoutes(): Promise<void>;
    getServers(): any[];
    bodyParser(type: string, opts: Record<string, any> | undefined): any;
    statics(endpoint: string, options: PlatformStaticsOptions): any;
    protected compose(layer: PlatformLayer): (req: FastifyRequest, reply: FastifyReply) => Promise<Promise<void>>;
    protected resolvePlugins(): Promise<PlatformFastifyPluginLoadingOptions[]>;
}

readonly NAME

ts
readonly NAME = "fastify";

static create

ts
static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<TsED.Application>;

Create new serverless application. In this mode, the component scan are disabled.

static bootstrap

ts
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<TsED.Application>>;

Bootstrap a server application

mapLayers

ts
mapLayers(layers: PlatformLayer[]): void;

mapHandler

ts
mapHandler(handler: (...args: any[]) => any, metadata: PlatformHandlerMetadata): (...args: any[]) => any;

useContext

ts
useContext(): Promise<void>;

createApp

ts
createApp(): {
     app: Fastify.FastifyInstance<Fastify.RawServerDefault, Http.IncomingMessage, Http.ServerResponse<Http.IncomingMessage>, Fastify.FastifyBaseLogger, Fastify.FastifyTypeProviderDefault>;
     callback: () => (request: IncomingMessage, response: ServerResponse) => Promise<void>;
 };

afterLoadRoutes

ts
afterLoadRoutes(): Promise<void>;

getServers

ts
getServers(): any[];

bodyParser

ts
bodyParser(type: string, opts: Record<string, any> | undefined): any;

statics

ts
statics(endpoint: string, options: PlatformStaticsOptions): any;

protected compose

ts
protected compose(layer: PlatformLayer): (req: FastifyRequest, reply: FastifyReply) => Promise<Promise<void>>;

protected resolvePlugins

ts
protected resolvePlugins(): Promise<PlatformFastifyPluginLoadingOptions[]>;

Released under the MIT License.