Skip to content

PlatformAdapter

@tsed/platform-http

Usage

typescript
import { PlatformAdapter } from "@tsed/platform-http";

See /packages/platform/platform-http/src/types/common/services/PlatformAdapter.ts.

Overview

ts
abstract class PlatformAdapter<App = TsED.Application> {
    abstract readonly NAME: string;
    providers: ProviderOpts[];
    get app(): PlatformApplication<App>;
    getServers(): CreateServerReturn[];
    onInit(): Promise<void> | void;
    beforeLoadRoutes(): Promise<void> | void;
    afterLoadRoutes(): Promise<void> | void;
    abstract useContext(): Promise<void> | void;
    abstract mapLayers(layer: PlatformLayer[]): void;
    mapHandler(handler: Function, layer: PlatformHandlerMetadata): Function;
    abstract createApp(): {
        app: App;
        callback(): (req: IncomingMessage, res: ServerResponse) => void;
    };
    abstract statics(endpoint: string, options: PlatformStaticsOptions): any;
    abstract multipart(options: PlatformMulterSettings): PlatformMulter;
    abstract bodyParser(type: string, opts?: Record<string, any>): any;
}

abstract readonly NAME

ts
abstract readonly NAME: string;

providers

ts
providers: ProviderOpts[];

Load providers in top priority

get app

ts
get app(): PlatformApplication<App>;

getServers

ts
getServers(): CreateServerReturn[];

onInit

ts
onInit(): Promise<void> | void;

beforeLoadRoutes

ts
beforeLoadRoutes(): Promise<void> | void;

afterLoadRoutes

ts
afterLoadRoutes(): Promise<void> | void;

abstract useContext

ts
abstract useContext(): Promise<void> | void;

create initial context

abstract mapLayers

ts
abstract mapLayers(layer: PlatformLayer[]): void;

Map router layer to the targeted framework

mapHandler

ts
mapHandler(handler: Function, layer: PlatformHandlerMetadata): Function;

Map handler to the targeted framework

abstract createApp

ts
abstract createApp(): {
     app: App;
     callback(): (req: IncomingMessage, res: ServerResponse) => void;
 };

Return the app instance

abstract statics

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

Return the statics middlewares

abstract multipart

ts
abstract multipart(options: PlatformMulterSettings): PlatformMulter;

Return the multipart middleware

abstract bodyParser

ts
abstract bodyParser(type: string, opts?: Record<string, any>): any;

Return the body parser for the given

Released under the MIT License.