# Class EndpointMetadata

Class
Module
import { EndpointMetadata } from "@tsed/common"
Source/packages/common/src/mvc/models/EndpointMetadata.ts

# Overview

class EndpointMetadata extends JsonEntityStore implements EndpointConstructorOptions {
    beforeMiddlewares: any[];
    middlewares: any[];
    afterMiddlewares: any[];
    statusCode: number;
    constructor(options: EndpointConstructorOptions);
    get targetName(): string;
    get params(): ParamMetadata[];
get <span class="token function">operation</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <a href="/api/schema/domain/JsonOperation.html"><span class="token">JsonOperation</span></a><span class="token punctuation">;</span>
get <span class="token function">operationPaths</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> Map&lt;<span class="token keyword">string</span><span class="token punctuation">,</span> <span class="token keyword">import</span><span class="token punctuation">(</span>"@tsed/schema"<span class="token punctuation">)</span>.<a href="/api/schema/domain/JsonMethodPath.html"><span class="token">JsonMethodPath</span></a>&gt;<span class="token punctuation">;</span>
get <span class="token function">view</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <a href="/api/common/mvc/models/EndpointViewOptions.html"><span class="token">EndpointViewOptions</span></a><span class="token punctuation">;</span>
set <span class="token function">view</span><span class="token punctuation">(</span>view<span class="token punctuation">:</span> <a href="/api/common/mvc/models/EndpointViewOptions.html"><span class="token">EndpointViewOptions</span></a><span class="token punctuation">)</span><span class="token punctuation">;</span>
get <span class="token function">location</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>
set <span class="token function">location</span><span class="token punctuation">(</span>url<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
get <span class="token function">acceptMimes</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><span class="token punctuation">]</span><span class="token punctuation">;</span>
set <span class="token function">acceptMimes</span><span class="token punctuation">(</span>mimes<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
get <span class="token function">redirect</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <a href="/api/common/mvc/models/EndpointRedirectOptions.html"><span class="token">EndpointRedirectOptions</span></a><span class="token punctuation">;</span>
set <span class="token function">redirect</span><span class="token punctuation">(</span>options<span class="token punctuation">:</span> <a href="/api/common/mvc/models/EndpointRedirectOptions.html"><span class="token">EndpointRedirectOptions</span></a><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">static</span> <span class="token function">getEndpoints</span><span class="token punctuation">(</span>target<span class="token punctuation">:</span> <a href="/api/core/interfaces/Type.html"><span class="token">Type</span></a>&lt;<span class="token keyword">any</span>&gt;<span class="token punctuation">)</span><span class="token punctuation">:</span> EndpointMetadata<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token keyword">static</span> <span class="token function">get</span><span class="token punctuation">(</span>target<span class="token punctuation">:</span> <a href="/api/core/interfaces/Type.html"><span class="token">Type</span></a>&lt;<span class="token keyword">any</span>&gt;<span class="token punctuation">,</span> propertyKey<span class="token punctuation">:</span> <span class="token keyword">string</span> | symbol<span class="token punctuation">,</span> descriptor?<span class="token punctuation">:</span> PropertyDescriptor<span class="token punctuation">)</span><span class="token punctuation">:</span> EndpointMetadata<span class="token punctuation">;</span>
<span class="token function">addOperationPath</span><span class="token punctuation">(</span>method<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">,</span> path<span class="token punctuation">:</span> <span class="token keyword">string</span> | RegExp<span class="token punctuation">,</span> options?<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <a href="/api/schema/domain/JsonOperation.html"><span class="token">JsonOperation</span></a><span class="token punctuation">;</span>

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

<span class="token function">before</span><span class="token punctuation">(</span>args<span class="token punctuation">:</span> Function<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">after</span><span class="token punctuation">(</span>args<span class="token punctuation">:</span> Function<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">use</span><span class="token punctuation">(</span>args<span class="token punctuation">:</span> Function<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">clone</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> EndpointMetadata<span class="token punctuation">;</span>

}

# Description

EndpointMetadata contains metadata about a controller and his method. Each annotation (@Get, @Body...) attached to a method are stored in a endpoint. EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.

Example :

@Controller("/my-path") provide MyClass {

   @Get("/")
   @Authenticated()
   public myMethod(){}

}

# Members

beforeMiddlewares: any[];

middlewares: any[];

afterMiddlewares: any[];

statusCode: number;

get targetName(): string;

get params(): ParamMetadata[];

get operation(): JsonOperation;

Return the JsonOperation


get operationPaths(): Map<string, import("@tsed/schema").JsonMethodPath>;

get view(): EndpointViewOptions;

set view(view: EndpointViewOptions);

get location(): string;

set location(url: string);

get acceptMimes(): string[];

set acceptMimes(mimes: string[]);

get redirect(): EndpointRedirectOptions;

set redirect(options: EndpointRedirectOptions);

static getEndpoints(target: Type<any>): EndpointMetadata[];

Get all endpoints from a given class and his parents.


static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): EndpointMetadata;

Get an endpoint.


addOperationPath(method: string, path: string | RegExp, options?: any): JsonOperation;

get<T = any>(key: any): T;

Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.


before(args: Function[]): this;

Append middlewares to the beforeMiddlewares list.


after(args: Function[]): this;

Append middlewares to the afterMiddlewares list.


use(args: Function[]): this;

Store all arguments collected via Annotation.


Other topics