Skip to main content

Annotations

@request#

Assign the Request object that represents the HTTP Request and all the properties defined in ExpressJS Request Object.

Example

GenericController.ts
class GenericController {  @Get('/') // This Response to all GET Requests for controller route.  methodError(@request req) {}}

@response#

Assign the Response object that represents the HTTP Response and all the properties defined in ExpressJS Request Object.

Example

GenericController.ts
class GenericController {  @Get('/') // This Response to all GET Requests for controller route.  methodError(@response res) {}}

@next#

Assign the middleware function Next for the request-response cycle, as same behavior as ExpressJS this will call next middleware in the stack.

Example

GenericController.ts
class GenericController {  @Get('/') // This Response to all GET Requests for controller route.  methodError(@next next) {}}

@query(
parameterOptional
:String| String[] | undefined
)#

This Decorator extract query string values from the current request and add it as argument value. This decorator is able to extract values the whole object by not passing any argument to the decorator, a partial patch passing a list of parameters name, or a single value when just passing a parameter name, if any of the asked value does not exist value will be undefined.

Parameters
NameOptionalTypeDefaultsDescription
parameterYesString| String[] | undefinedString: returns the query argument associated to the name.
String[]: returns the query argument associated to the name.
undefined: returns the query argument associated to the name.
Other case is returning undefined.

Example

GenericController.ts
class GenericController {    @Get('/') // This Response to all GET Requests for controller route.    method(@query() query) {}    method2(@query('username') username) {}    method3(@query(['username', 'password']) credentials) {}}

@body(
bodyParamOptional
:String| String[] | undefined
)#

This Decorator extract body param values from the current request and add it as argument value. This decorator is able to extract values the whole object by not passing any argument to the decorator, a partial patch passing a list of parameters name, or a single value when just passing a parameter name, if any of the asked value does not exist value will be undefined.

As Expressive Tea does not come with a Body Parser configurations out of the box, this requires user setup prior use this decorator. You will be able to get one Body Parser here.

Parameters
NameOptionalTypeDefaultsDescription
bodyParamYesString| String[] | undefinedString: returns the query argument associated to the name.
String[]: returns the query argument associated to the name.
undefined: returns the query argument associated to the name.
Other case is returning undefined.

Example

class GenericController {    @Get('/') // This Response to all GET Requests for controller route.    method(@body() body) {}    method2(@body('username') username) {}    method3(@body(['username', 'password']) credentials) {}}

@param(
parameter
:String
)#

It will return the value defined on the url path for the current method or a global middleware, this only works for single parameter, also might be side affected if there is an any param decorator declared in the current controller.

Example

class GenericController {    @Get('/:userId') // This Response to all GET Requests for controller route.    method(@param('userId') username) {}}