# Class PlatformContext

Class private
Module
import { PlatformContext } from "@tsed/platform/common/src/domain/PlatformContext"
Source/packages/platform/common/src/domain/PlatformContext.ts

# Overview

class PlatformContext extends DIContext implements ContextMethods {
endpoint<span class="token punctuation">:</span> <a href="/api/platform/common/domain/EndpointMetadata.html"><span class="token">EndpointMetadata</span></a><span class="token punctuation">;</span>

data<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>

response<span class="token punctuation">:</span> <a href="/api/platform/common/services/PlatformResponse.html"><span class="token">PlatformResponse</span></a><span class="token punctuation">;</span>

request<span class="token punctuation">:</span> <a href="/api/platform/common/services/PlatformRequest.html"><span class="token">PlatformRequest</span></a><span class="token punctuation">;</span>

<span class="token keyword">constructor</span><span class="token punctuation">(</span><span class="token punctuation">{</span> event<span class="token punctuation">,</span> endpoint<span class="token punctuation">,</span> ignoreUrlPatterns<span class="token punctuation">,</span> ResponseKlass<span class="token punctuation">,</span> RequestKlass<span class="token punctuation">,</span> ...options <span class="token punctuation">}</span><span class="token punctuation">:</span> <a href="/api/platform/common/domain/PlatformContextOptions.html"><span class="token">PlatformContextOptions</span></a><span class="token punctuation">)</span><span class="token punctuation">;</span>
get <span class="token function">url</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">;</span>
get <span class="token function">app</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <a href="/api/platform/common/services/PlatformApplication.html"><span class="token">PlatformApplication</span></a>&lt;TsED.Application<span class="token punctuation">,</span> TsED.Router&gt;<span class="token punctuation">;</span>
<span class="token function">destroy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> Promise&lt;<span class="token keyword">void</span>&gt;<span class="token punctuation">;</span>
<span class="token function">isDone</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">boolean</span><span class="token punctuation">;</span>

getRequest&lt;<a href="/api/platform/common/decorators/params/Req.html"><span class="token">Req</span></a><span class="token punctuation"> = </span><span class="token keyword">any</span>&gt;<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <a href="/api/platform/common/decorators/params/Req.html"><span class="token">Req</span></a><span class="token punctuation">;</span>

getResponse&lt;<a href="/api/platform/common/decorators/params/Res.html"><span class="token">Res</span></a><span class="token punctuation"> = </span><span class="token keyword">any</span>&gt;<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <a href="/api/platform/common/decorators/params/Res.html"><span class="token">Res</span></a><span class="token punctuation">;</span>

<span class="token function">getReq</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> IncomingMessage<span class="token punctuation">;</span>

<span class="token function">getRes</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> ServerResponse<span class="token punctuation">;</span>

getApp&lt;T<span class="token punctuation"> = </span><span class="token keyword">any</span>&gt;<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> T<span class="token punctuation">;</span>

}

# Members

endpoint: EndpointMetadata;

The current EndpointMetadata resolved by Ts.ED during the request.


data: any;

The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.


response: PlatformResponse;

The current PlatformResponse.


request: PlatformRequest;

The current PlatformRequest.


get url(): string;

get app(): PlatformApplication<TsED.Application, TsED.Router>;

destroy(): Promise<void>;

isDone(): boolean;

getRequest<Req = any>(): Req;

Return the framework request instance (Express, Koa, etc...)


getResponse<Res = any>(): Res;

Return the framework response instance (Express, Koa, etc...)


getReq(): IncomingMessage;

Get Node.js request


getRes(): ServerResponse;

Get Node.js response


getApp<T = any>(): T;

Return the original application instance.

Other topics