# EndpointMetadata Class

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

# Overview

class EndpointMetadata extends Storable implements EndpointConstructorOptions {
    provide: Type<any>;
    beforeMiddlewares: any[];
    middlewares: any[];
    afterMiddlewares: any[];
    /**
     * Route strategy.
     */
    pathsMethods: IPathMethod[];
    readonly responses: Map<number, IResponseOptions>;
    statusCode: number;
    constructor(options: EndpointConstructorOptions);
    get type(): Type<any>;
    set type(type: Type<any>);
    get targetName(): string;
    get params(): ParamMetadata[];
    get response(): IResponseOptions;
    /**
     * Get all endpoints from a given class and his parents.
     * @param {Type<any>} target
     * @returns {EndpointMetadata[]}
     */
    static getEndpoints(target: Type<any>): EndpointMetadata[];
    /**
     * Get an endpoint.
     * @param target
     * @param propertyKey
     * @param descriptor
     */
    static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): EndpointMetadata;
    /**
     * Gets a value indicating whether the target object or its prototype chain has already method registered.
     * @param target
     * @param method
     * @deprecated
     */
    static has(target: Type<any>, method: string | symbol): boolean;
    /**
     * Append mvc in the pool (before).
     * @param target
     * @param targetKey
     * @param args
     * @deprecated
     */
    static useBefore(target: Type<any>, targetKey: string | symbol, args: any[]): typeof EndpointMetadata;
    /**
     * Add middleware and configuration for the endpoint.
     * @param target
     * @param targetKey
     * @param args
     * @returns {Endpoint}
     * @deprecated
     */
    static use(target: Type<any>, targetKey: string | symbol, args: any[]): typeof EndpointMetadata;
    /**
     * Append mvc in the pool (after).
     * @param target
     * @param targetKey
     * @param args
     * @deprecated
     */
    static useAfter(target: Type<any>, targetKey: string | symbol, args: any[]): typeof EndpointMetadata;
    /**
     * Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.
     *
     * @param key
     * @returns {any}
     */
    get<T = any>(key: any): T;
    /**
     * Change the type and the collection type from the status code.
     * @param {string | number} code
     * @deprecated Use endpoint.responses.get(code)
     */
    statusResponse(code: string | number): IResponseOptions;
    /**
     *
     * @param args
     * @returns {EndpointMetadata}
     */
    before(args: Function[]): this;
    /**
     *
     * @param args
     * @returns {EndpointMetadata}
     */
    after(args: Function[]): this;
    /**
     * Store all arguments collected via Annotation.
     * @param args
     */
    use(args: Function[]): this;
    /**
     * Store all arguments collected via Annotation.
     * @param args
     * @deprecated
     */
    merge(args: any[]): this;
    clone(): EndpointMetadata;
}

# 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(){}

}