Skip to main content

Decorators

Here is a complete list of all decorators available in ExpressoTS as well as a brief description of what they do.

Class Decorators

Decorators available for your classes.

DecoratorDescription
@provideBinds a class to a dependency injection container as RequestScope.
@provideSingletonBinds a class to a dependency injection container as Singleton.
@provideTransientBinds a class to a dependency injection container as Transient.
@injectableMarks a class as available to be injected.
@injectMarks a class as available to be injected in the constructor of another class.

Controller Decorators

Decorators available for your controllers.

DecoratorDescriptionUsage example
@controllerMarks a class as a controller.@controller("/path", middleware[])
@scopeBinds a controller to a scope.@scope(BindingScopeEnum.Singleton, or Request, or Transient)

HTTP Method Decorators

Decorators available for your controller methods.

DecoratorDescriptionUsage
@GetBinds a controller method to a GET HTTP verb.@Get("/path")
@PostBinds a controller method to a POST HTTP verb.@Post("/path")
@PutBinds a controller method to a PUT HTTP verb.@Put("/path")
@PatchBinds a controller method to a PATCH HTTP verb.@Patch("/path")
@HeadBinds a controller method to a HEAD HTTP verb.@Head("/path")
@DeleteBinds a controller method to a DELETE HTTP verb.@Delete("/path")
@MethodBinds a controller method to a specified HTTP verb.@Method("verb", "/path")

Parameter Decorators

Here is a list of all parameter decorators available in ExpressoTS, along with their description and usage:

DecoratorDescriptionUsage
@request()Injects the Express Request object.execute(@request() req: Request)
@response()Injects the Express Response object.execute(@response() res: Response)
@param(paramName?: string)Injects a parameter from the request URL path.execute(@param('id') id: string)
@query(paramName?: string)Injects a parameter from the request URL query string.execute(@query('searchTerm') searchTerm: string)
@body()Injects the request body payload.execute(@body() body: MyDTO)
@headers(headerName?: string)Injects a header from the request headers.execute(@headers('authorization') auth: string)
@cookies(cookieName?: string)Injects a cookie from the request cookies.execute(@cookies('session') session: string)
@next()Injects the Express NextFunction object.execute(@next() next: NextFunction)

Support the Project

ExpressoTS is an MIT-licensed open source project. It's an independent project with ongoing development made possible thanks to your support. If you'd like to help, please consider: