Controller

Decorator that marks a class as a Nest controller that can receive inbound requests and produce responses.

See more...


 @Controller(prefixOrOptions?: string | string[] | ControllerOptions)

Parameters

Option Type Description
prefixOrOptions string | string[] | ControllerOptions

a route path prefix or a ControllerOptions object. A route path prefix is pre-pended to the path specified in any request decorator in the class. ControllerOptions is an options configuration object specifying:

  • scope - symbol that determines the lifetime of a Controller instance. See Scope for more details.
  • prefix - string that defines a route path prefix. The prefix is pre-pended to the path specified in any request decorator in the class.
  • version - string, array of strings, or Symbol that defines the version of all routes in the class. See Versioning for more details.

Optional. Default is `undefined`.

Returns

ClassDecorator

See also

Description

An HTTP Controller responds to inbound HTTP Requests and produces HTTP Responses. It defines a class that provides the context for one or more related route handlers that correspond to HTTP request methods and associated routes for example GET /api/profile, POST /users/resume

A Microservice Controller responds to requests as well as events, running over a variety of transports (read more here). It defines a class that provides a context for one or more message or event handlers.