# Class PlatformRouter

Class platform
Module
import { PlatformRouter } from "@tsed/common"
Source/packages/common/src/platform/services/PlatformRouter.ts

# Overview

class PlatformRouter<Router = TsED.Router> {
    protected platformHandler: PlatformHandler;
    rawRouter: Router;
    raw: any;
    injector: InjectorService;
    constructor(platformHandler: PlatformHandler);
<span class="token keyword">static</span> <span class="token function">create</span><span class="token punctuation">(</span>injector<span class="token punctuation">:</span> <a href="/api/di/services/InjectorService.html"><span class="token">InjectorService</span></a><span class="token punctuation">,</span> routerOptions?<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">:</span> PlatformRouter&lt;TsED.Router&gt;<span class="token punctuation">;</span>
<span class="token keyword">protected</span> <span class="token keyword">static</span> <span class="token function">createRawRouter</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>
<span class="token function">callback</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>
<span class="token function">getRouter</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> Router<span class="token punctuation">;</span>
<span class="token function">use</span><span class="token punctuation">(</span>...handlers<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">addRoute</span><span class="token punctuation">(</span>options<span class="token punctuation">:</span> PlatformRouteOptions<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">all</span><span class="token punctuation">(</span>path<span class="token punctuation">:</span> <a href="/api/common/mvc/interfaces/PathParamsType.html"><span class="token">PathParamsType</span></a><span class="token punctuation">,</span> ...handlers<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">get</span><span class="token punctuation">(</span>path<span class="token punctuation">:</span> <a href="/api/common/mvc/interfaces/PathParamsType.html"><span class="token">PathParamsType</span></a><span class="token punctuation">,</span> ...handlers<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">post</span><span class="token punctuation">(</span>path<span class="token punctuation">:</span> <a href="/api/common/mvc/interfaces/PathParamsType.html"><span class="token">PathParamsType</span></a><span class="token punctuation">,</span> ...handlers<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">put</span><span class="token punctuation">(</span>path<span class="token punctuation">:</span> <a href="/api/common/mvc/interfaces/PathParamsType.html"><span class="token">PathParamsType</span></a><span class="token punctuation">,</span> ...handlers<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">delete</span><span class="token punctuation">(</span>path<span class="token punctuation">:</span> <a href="/api/common/mvc/interfaces/PathParamsType.html"><span class="token">PathParamsType</span></a><span class="token punctuation">,</span> ...handlers<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">patch</span><span class="token punctuation">(</span>path<span class="token punctuation">:</span> <a href="/api/common/mvc/interfaces/PathParamsType.html"><span class="token">PathParamsType</span></a><span class="token punctuation">,</span> ...handlers<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">head</span><span class="token punctuation">(</span>path<span class="token punctuation">:</span> <a href="/api/common/mvc/interfaces/PathParamsType.html"><span class="token">PathParamsType</span></a><span class="token punctuation">,</span> ...handlers<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">options</span><span class="token punctuation">(</span>path<span class="token punctuation">:</span> <a href="/api/common/mvc/interfaces/PathParamsType.html"><span class="token">PathParamsType</span></a><span class="token punctuation">,</span> ...handlers<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">statics</span><span class="token punctuation">(</span>path<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">,</span> options<span class="token punctuation">:</span> <a href="/api/common/config/interfaces/PlatformStaticsOptions.html"><span class="token">PlatformStaticsOptions</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">multer</span><span class="token punctuation">(</span>options<span class="token punctuation">:</span> <a href="/api/common/config/interfaces/PlatformMulterSettings.html"><span class="token">PlatformMulterSettings</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <a href="/api/common/config/interfaces/PlatformMulter.html"><span class="token">PlatformMulter</span></a><span class="token punctuation">;</span>
<span class="token keyword">protected</span> <span class="token function">mapHandlers</span><span class="token punctuation">(</span>handlers<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span> options?<span class="token punctuation">:</span> PlatformRouteWithoutHandlers<span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

}

# Description

Platform Router abstraction layer.

# Members

protected platformHandler: PlatformHandler;

rawRouter: Router;

raw: any;

injector: InjectorService;

static create(injector: InjectorService, routerOptions?: any): PlatformRouter<TsED.Router>;

Create a new instance of PlatformRouter


protected static createRawRouter(): any;

callback(): any;

getRouter(): Router;

use(...handlers: any[]): this;

addRoute(options: PlatformRouteOptions): this;

all(path: PathParamsType, ...handlers: any[]): this;

get(path: PathParamsType, ...handlers: any[]): this;

post(path: PathParamsType, ...handlers: any[]): this;

put(path: PathParamsType, ...handlers: any[]): this;

delete(path: PathParamsType, ...handlers: any[]): this;

patch(path: PathParamsType, ...handlers: any[]): this;

head(path: PathParamsType, ...handlers: any[]): this;

options(path: PathParamsType, ...handlers: any[]): this;

statics(path: string, options: PlatformStaticsOptions): this;


protected mapHandlers(handlers: any[], options?: PlatformRouteWithoutHandlers): any[];

Other topics