Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "decorators"

Index

Functions

Accept

  • Accept(...accepts: string[]): (Anonymous function)
  • A decorator to tell the Server that a class or a method should only accept requests from clients that accepts one of the supported mime types.

    For example:

    @ Path("accept")
    @ Accept("application/json")
    class TestAcceptService {
         // ...
    }
    

    Will reject requests that only accepts mime types that are not "application/json""

    If the mime type requested is not supported, a status code 406 returned

    Parameters

    • Rest ...accepts: string[]

    Returns (Anonymous function)

AcceptLanguage

  • AcceptLanguage(...languages: string[]): (Anonymous function)
  • A decorator to tell the Server that a class or a method should only accept requests from clients that accepts one of the supported languages.

    For example:

    @ Path("accept")
    @ AcceptLanguage("en", "pt-BR")
    class TestAcceptService {
         // ...
    }
    

    Will reject requests that only accepts languages that are not English or Brazilian portuguese

    If the language requested is not supported, a status code 406 returned

    Parameters

    • Rest ...languages: string[]

    Returns (Anonymous function)

AcceptLanguageMethodDecorator

  • AcceptLanguageMethodDecorator(target: any, propertyKey: string, descriptor: PropertyDescriptor, languages: string[]): void
  • Decorator processor for AcceptLanguage decorator on methods

    Parameters

    • target: any
    • propertyKey: string
    • descriptor: PropertyDescriptor
    • languages: string[]

    Returns void

AcceptLanguageTypeDecorator

  • AcceptLanguageTypeDecorator(target: Function, languages: string[]): void

AcceptMethodDecorator

  • AcceptMethodDecorator(target: any, propertyKey: string, descriptor: PropertyDescriptor, accepts: string[]): void
  • Decorator processor for Accept decorator on methods

    Parameters

    • target: any
    • propertyKey: string
    • descriptor: PropertyDescriptor
    • accepts: string[]

    Returns void

AcceptTypeDecorator

  • AcceptTypeDecorator(target: Function, accepts: string[]): void
  • Decorator processor for Accept decorator on classes

    Parameters

    • target: Function
    • accepts: string[]

    Returns void

BodyOptions

  • BodyOptions(options: any): (Anonymous function)
  • A decorator to inform options to pe passed to bodyParser. You can inform any property accepted by [bodyParser]

    Parameters

    • options: any

    Returns (Anonymous function)

Context

  • Context(...args: any[]): any
  • A decorator to be used on class properties or on service method arguments to inform that the decorated property or argument should be bound to the ServiceContext object associated to the current request.

    For example:

    @ Path("context")
    class TestService {
      @ Context
    context: ServiceContext;
          // ...
    }
    

    The field context on the above class will point to the current ServiceContext instance.

    Parameters

    • Rest ...args: any[]

    Returns any

ContextAccept

  • ContextAccept(...args: any[]): any
  • A decorator to be used on class properties or on service method arguments to inform that the decorated property or argument should be bound to the the preferred media type for the current request.

    For example:

    @ Path("context")
    class TestService {
      @ ContextAccept
      media: string
          // ...
    }
    

    Parameters

    • Rest ...args: any[]

    Returns any

ContextLanguage

  • ContextLanguage(...args: any[]): any
  • A decorator to be used on class properties or on service method arguments to inform that the decorated property or argument should be bound to the the current context language.

    For example:

    @ Path("context")
    class TestService {
      @ ContextLanguage
      language: string
          // ...
    }
    

    Parameters

    • Rest ...args: any[]

    Returns any

ContextNext

  • ContextNext(...args: any[]): any
  • A decorator to be used on class properties or on service method arguments to inform that the decorated property or argument should be bound to the the next function.

    For example:

    @ Path("context")
    class TestService {
      @ ContextNext
      next: express.NextFunction
          // ...
    }
    

    The next function can be used to delegate to the next registered middleware the current request processing.

    Parameters

    • Rest ...args: any[]

    Returns any

ContextRequest

  • ContextRequest(...args: any[]): any
  • A decorator to be used on class properties or on service method arguments to inform that the decorated property or argument should be bound to the the current request.

    For example:

    @ Path("context")
    class TestService {
      @ ContextRequest
    request: express.Request;
          // ...
    }
    

    The field request on the above class will point to the current request.

    Parameters

    • Rest ...args: any[]

    Returns any

ContextResponse

  • ContextResponse(...args: any[]): any
  • A decorator to be used on class properties or on service method arguments to inform that the decorated property or argument should be bound to the the current response object.

    For example:

    @ Path("context")
    class TestService {
      @ ContextResponse
    response: express.Response;
          // ...
    }
    

    The field response on the above class will point to the current response object.

    Parameters

    • Rest ...args: any[]

    Returns any

CookieParam

  • CookieParam(name: string): (Anonymous function)
  • Creates a mapping between a cookie on request and a method argument.

    For example:

    @ Path("people")
    class PeopleService {
      @ GET
      getPeople(@ CookieParam("cookie") cookie: string) {
         // ...
      }
    }
    

    Will create a service that listen for requests and bind the cookie called "cookie" to the cookie argument on getPerson method's call.

    Parameters

    • name: string

    Returns (Anonymous function)

DELETE

  • DELETE(target: any, propertyKey: string, descriptor: PropertyDescriptor): void
  • A decorator to tell the Server that a method should be called to process HTTP DELETE requests.

    For example:

    @ Path("people")
    class PeopleService {
      @ DELETE
      @ Path(":id")
      removePerson(@ PathParam("id")id: string) {
         // ...
      }
    }
    

    Will create a service that listen for requests like:

    PUT http://mydomain/people/123
    

    Parameters

    • target: any
    • propertyKey: string
    • descriptor: PropertyDescriptor

    Returns void

FileParam

  • FileParam(name: string): (Anonymous function)
  • Creates a mapping between a file on a multipart request and a method argument.

    For example:

    @ Path("people")
    class PeopleService {
      @ POST
      @ Path("id")
      addAvatar(@ PathParam("id") id: string,
                @ FileParam("avatar") file: Express.Multer.File) {
         // ...
      }
    }
    

    Will create a service that listen for requests and bind the file with name "avatar" on the requested form to the file argument on addAvatar method's call.

    Parameters

    • name: string

    Returns (Anonymous function)

FilesParam

  • FilesParam(name: string): (Anonymous function)
  • Creates a mapping between a list of files on a multipart request and a method argument.

    For example:

    @ Path("people")
    class PeopleService {
      @ POST
      @ Path("id")
      addAvatar(@ PathParam("id") id: string,
                @ FilesParam("avatar") Array<file>: Express.Multer.File) {
         // ...
      }
    }
    

    Will create a service that listen for requests and bind the files with name "avatar" on the request form to the file argument on addAvatar method's call.

    Parameters

    • name: string

    Returns (Anonymous function)

FormParam

  • FormParam(name: string): (Anonymous function)
  • Creates a mapping between a form parameter on request and a method argument.

    For example:

    @ Path("people")
    class PeopleService {
      @ GET
      getPeople(@ FormParam("name") name: string) {
         // ...
      }
    }
    

    Will create a service that listen for requests and bind the request paramenter called "name" to the name argument on getPerson method's call.

    Parameters

    • name: string

    Returns (Anonymous function)

GET

  • GET(target: any, propertyKey: string, descriptor: PropertyDescriptor): void
  • A decorator to tell the Server that a method should be called to process HTTP GET requests.

    For example:

    @ Path("people")
    class PeopleService {
      @ GET
      getPeople() {
         // ...
      }
    }
    

    Will create a service that listen for requests like:

    GET http://mydomain/people
    

    Parameters

    • target: any
    • propertyKey: string
    • descriptor: PropertyDescriptor

    Returns void

HEAD

  • HEAD(target: any, propertyKey: string, descriptor: PropertyDescriptor): void
  • A decorator to tell the Server that a method should be called to process HTTP HEAD requests.

    For example:

    @ Path("people")
    class PeopleService {
      @ HEAD
      headPerson() {
         // ...
      }
    }
    

    Will create a service that listen for requests like:

    HEAD http://mydomain/people/123
    

    Parameters

    • target: any
    • propertyKey: string
    • descriptor: PropertyDescriptor

    Returns void

HeaderParam

  • HeaderParam(name: string): (Anonymous function)
  • Creates a mapping between a header on request and a method argument.

    For example:

    @ Path("people")
    class PeopleService {
      @ GET
      getPeople(@ HeaderParam("header") header: string) {
         // ...
      }
    }
    

    Will create a service that listen for requests and bind the header called "header" to the header argument on getPerson method's call.

    Parameters

    • name: string

    Returns (Anonymous function)

OPTIONS

  • OPTIONS(target: any, propertyKey: string, descriptor: PropertyDescriptor): void
  • A decorator to tell the Server that a method should be called to process HTTP OPTIONS requests.

    For example:

    @ Path("people")
    class PeopleService {
      @ OPTIONS
      optionsPerson() {
         // ...
      }
    }
    

    Will create a service that listen for requests like:

    OPTIONS http://mydomain/people/123
    

    Parameters

    • target: any
    • propertyKey: string
    • descriptor: PropertyDescriptor

    Returns void

PATCH

  • PATCH(target: any, propertyKey: string, descriptor: PropertyDescriptor): void
  • A decorator to tell the Server that a method should be called to process HTTP PATCH requests.

    For example:

    @ Path("people")
    class PeopleService {
      @ PATCH
      @ Path(":id")
      savePerson(person: Person) {
         // ...
      }
    }
    

    Will create a service that listen for requests like:

    PATCH http://mydomain/people/123
    

    Parameters

    • target: any
    • propertyKey: string
    • descriptor: PropertyDescriptor

    Returns void

POST

  • POST(target: any, propertyKey: string, descriptor: PropertyDescriptor): void
  • A decorator to tell the Server that a method should be called to process HTTP POST requests.

    For example:

    @ Path("people")
    class PeopleService {
      @ POST
      addPerson() {
         // ...
      }
    }
    

    Will create a service that listen for requests like:

    POST http://mydomain/people
    

    Parameters

    • target: any
    • propertyKey: string
    • descriptor: PropertyDescriptor

    Returns void

PUT

  • PUT(target: any, propertyKey: string, descriptor: PropertyDescriptor): void
  • A decorator to tell the Server that a method should be called to process HTTP PUT requests.

    For example:

    @ Path("people")
    class PeopleService {
      @ PUT
      @ Path(":id")
      savePerson(person: Person) {
         // ...
      }
    }
    

    Will create a service that listen for requests like:

    PUT http://mydomain/people/123
    

    Parameters

    • target: any
    • propertyKey: string
    • descriptor: PropertyDescriptor

    Returns void

Param

  • Param(name: string): (Anonymous function)
  • Creates a mapping between a parameter on request and a method argument.

    For example:

    @ Path("people")
    class PeopleService {
      @ GET
      getPeople(@ Param("name") name: string) {
         // ...
      }
    }
    

    Will create a service that listen for requests and bind the request paramenter called "name" to the name argument on getPerson method's call. It will work to query parameters or form parameters received in the current request.

    Parameters

    • name: string

    Returns (Anonymous function)

Path

  • Path(path: string): (Anonymous function)
  • A decorator to tell the Server that a class or a method should be bound to a given path.

    For example:

    @ Path("people")
    class PeopleService {
      @ PUT
      @ Path(":id")
      savePerson(person:Person) {
         // ...
      }
    
      @ GET
      @ Path(":id")
      getPerson():Person {
         // ...
      }
    }
    

    Will create services that listen for requests like:

    PUT http://mydomain/people/123 or
    GET http://mydomain/people/123
    

    Parameters

    • path: string

    Returns (Anonymous function)

PathMethodDecorator

  • PathMethodDecorator(target: any, propertyKey: string, descriptor: PropertyDescriptor, path: string): void
  • Decorator processor for Path decorator on methods

    Parameters

    • target: any
    • propertyKey: string
    • descriptor: PropertyDescriptor
    • path: string

    Returns void

PathParam

  • PathParam(name: string): (Anonymous function)
  • Creates a mapping between a fragment of the requested path and a method argument.

    For example:

    @ Path("people")
    class PeopleService {
      @ GET
      @ Path(":id")
      getPerson(@ PathParam("id") id: string) {
         // ...
      }
    }
    

    Will create a service that listen for requests like:

    GET http://mydomain/people/123
    

    And pass 123 as the id argument on getPerson method's call.

    Parameters

    • name: string

    Returns (Anonymous function)

PathTypeDecorator

  • PathTypeDecorator(target: Function, path: string): void
  • Decorator processor for Path decorator on classes

    Parameters

    • target: Function
    • path: string

    Returns void

QueryParam

  • QueryParam(name: string): (Anonymous function)
  • Creates a mapping between a query parameter on request and a method argument.

    For example:

    @ Path("people")
    class PeopleService {
      @ GET
      getPeople(@ QueryParam("name") name: string) {
         // ...
      }
    }
    

    Will create a service that listen for requests like:

    GET http://mydomain/people?name=joe
    

    And pass "joe" as the name argument on getPerson method's call.

    Parameters

    • name: string

    Returns (Anonymous function)

processDecoratedParameter

  • processDecoratedParameter(target: Object, propertyKey: string, parameterIndex: number, paramType: ParamType, name: string): void
  • Decorator processor for parameter annotations on methods

    Parameters

    • target: Object
    • propertyKey: string
    • parameterIndex: number
    • paramType: ParamType
    • name: string

    Returns void

processDecoratedProperty

  • processDecoratedProperty(target: Function, key: string, paramType: ParamType): void
  • Decorator processor for annotations on properties

    Parameters

    • target: Function
    • key: string
    • paramType: ParamType

    Returns void

processHttpVerb

  • processHttpVerb(target: any, propertyKey: string, httpMethod: HttpMethod): void
  • Decorator processor for HTTP verb annotations on methods

    Parameters

    • target: any
    • propertyKey: string
    • httpMethod: HttpMethod

    Returns void

processServiceMethod

  • processServiceMethod(target: any, propertyKey: string, serviceMethod: ServiceMethod): void

Generated using TypeDoc