EndpointMetadata Class

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

Overview

class EndpointMetadata extends Storable {
    constructor(_provide: Type<;any>;, _methodClassName: string);
    beforeMiddlewares: any[];
    middlewares: any[];
    afterMiddlewares: any[];
    httpMethod: string;
    path: PathParamsType;
    readonly inheritedEndpoint: EndpointMetadata;
    type: Type<;any>;;
    pathsMethods: ExpressPathMethod[];
    readonly methodClassName: string;
    readonly store: Store;
    get(key: any): any;
    hasHttpMethod(): boolean;
    statusResponse(code: string | number): {
        description: string;
        headers: any;
        examples: any;
    };
    before(args: any[]): this;
    after(args: any[]): this;
    merge(args: any[]): this;
    inherit(target: Type<;any>;): 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(){}

}

Constructor

constructor(_provide: Type<;any>;, _methodClassName: string)

Endpoint inherited from parent class.

Members

beforeMiddlewares: any[]

middlewares: any[]

afterMiddlewares: any[]

httpMethod: string


readonly inheritedEndpoint: EndpointMetadata

type: Type<;any>;

pathsMethods: ExpressPathMethod[]

readonly methodClassName: string

readonly store: Store

get(key: any): any

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


hasHttpMethod(): boolean

statusResponse(code: string | number): {
     description: string;
     headers: any;
     examples: any;
 };

Change the type and the collection type from the status code.


before(args: any[]): this

after(args: any[]): this

merge(args: any[]): this

Store all arguments collected via Annotation.


inherit(target: Type<;any>;): EndpointMetadata