Set origin to a function implementing some custom logic. The function takes the request origin as the first parameter and a callback (which expects the signature err [object], allow [bool]) as the second.
Defines the injection scope.
Route handler (method) Decorator. Routes all HTTP requests to the specified path.
Create a new instance of Axios
The default config for the instance
Route handler (method) Decorator. Routes HTTP DELETE requests to the specified path.
Route handler (method) Decorator. Routes HTTP GET requests to the specified path.
Route handler (method) Decorator. Routes HTTP HEAD requests to the specified path.
Route handler parameter decorator. Extracts the headers
property from the req
object and populates the decorated
parameter with the value of headers
.
For example: async update(@Headers('Cache-Control') cacheControl: string)
Route handler parameter decorator. Extracts the Ip
property
from the req
object and populates the decorated
parameter with the value of ip
.
Route handler parameter decorator. Extracts reference to the Next
function
from the underlying platform and populates the decorated
parameter with the value of Next
.
Route handler (method) Decorator. Routes HTTP OPTIONS requests to the specified path.
Route handler (method) Decorator. Routes HTTP PATCH requests to the specified path.
Route handler (method) Decorator. Routes HTTP POST requests to the specified path.
Route handler (method) Decorator. Routes HTTP PUT requests to the specified path.
Route handler parameter decorator. Extracts the Request
object from the underlying platform and populates the decorated
parameter with the value of Request
.
Example: logout(@Request() req)
Route handler parameter decorator. Extracts the Session
object
from the underlying platform and populates the decorated
parameter with the value of Session
.
Route handler parameter decorator. Extracts the file
object
and populates the decorated parameter with the value of file
.
Used in conjunction with
multer middleware.
For example:
uploadFile(@UploadedFile() file) {
console.log(file);
}
Route handler parameter decorator. Extracts the files
object
and populates the decorated parameter with the value of files
.
Used in conjunction with
multer middleware.
For example:
uploadFile(@UploadedFiles() files) {
console.log(files);
}
Convert array of 16 byte values to UUID string format of the form: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX Convert array of 16 byte values to UUID string format of the form: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX Convert array of 16 byte values to UUID string format of the form: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Decorator that binds parameter decorators to the method that follows.
Useful when the language doesn't provide a 'Parameter Decorator' feature (i.e., vanilla JavaScript).
one or more parameter decorators (e.g., Req()
)
Route handler parameter decorator. Extracts the entire body
object from the req
object and populates the decorated
parameter with the value of body
.
For example:
async create(@Body() cat: CreateCatDto)
Route handler parameter decorator. Extracts the entire body
object from the req
object and populates the decorated
parameter with the value of body
. Also applies the specified
pipes to that parameter.
For example:
async create(@Body(new ValidationPipe()) cat: CreateCatDto)
one or more pipes - either instances or classes - to apply to the bound body parameter.
Route handler parameter decorator. Extracts a single property from
the body
object property of the req
object and populates the decorated
parameter with the value of that property. Also applies pipes to the bound
body parameter.
For example:
async create(@Body('role', new ValidationPipe()) role: string)
name of single property to extract from the body
object
one or more pipes - either instances or classes - to apply to the bound body parameter.
Decorator that sets the caching key used to store/retrieve cached items for Web sockets or Microservice based apps.
For example:
@CacheKey('events')
string naming the field to be used as a cache key
A Cancel
is an object that is thrown when an operation is canceled.
The message.
A CancelToken
is an object that can be used to request cancellation of an operation.
The executor function.
Decorator that marks a class as a Nest exception filter. An exception filter handles exceptions thrown by or not handled by your application code.
The decorated class must implement the ExceptionFilter
interface.
one or more exception types specifying the exceptions to be caught and handled by this filter.
Decorator that marks a class as a Nest controller that can receive inbound requests and produce responses.
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 /user/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.
Decorator that marks a class as a Nest controller that can receive inbound requests and produce responses.
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 /user/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.
string that defines a route path prefix
. The prefix
is pre-pended to the path specified in any request decorator in the class.
Decorator that marks a class as a Nest controller that can receive inbound requests and produce responses.
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 /user/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.
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.Decorator that sets required dependencies (required with a vanilla JavaScript objects)
Decorator that makes a module global-scoped.
Once imported into any module, a global-scoped module will be visible in all modules. Thereafter, modules that wish to inject a service exported from a global module do not need to import the provider module.
Request method Decorator. Sets a response header.
For example:
@Header('Cache-Control', 'none')
string to be used for header name
string to be used for header value
Route handler parameter decorator. Extracts the hosts
property from the req
object and populates the decorated
parameter with the value of hosts
. May also apply pipes to the bound
parameter.
For example, extracting all params:
findOne(@HostParam() params: string[])
For example, extracting a single param:
findOne(@HostParam('id') id: string)
Route handler parameter decorator. Extracts the hosts
property from the req
object and populates the decorated
parameter with the value of hosts
. May also apply pipes to the bound
parameter.
For example, extracting all params:
findOne(@HostParam() params: string[])
For example, extracting a single param:
findOne(@HostParam('id') id: string)
name of single property to extract from the req
object
Request method Decorator. Defines the HTTP response status code. Overrides default status code for the decorated request method.
HTTP response code to be returned by route handler.
Decorator that marks a constructor parameter as a target for Dependency Injection (DI).
Any injected provider must be visible within the module scope (loosely speaking, the containing module) of the class it is being injected into. This can be done by:
@Global()
decoratorCan be types (class names), strings or symbols. This depends on how the
provider with which it is associated was defined. Providers defined with the
@Injectable()
decorator use the class name. Custom Providers may use strings
or symbols as the injection token.
lookup key for the provider to be injected (assigned to the constructor parameter).
Decorator that marks a class as a provider. Providers can be injected into other classes via constructor parameter injection using Nest's built-in Dependency Injection (DI) system.
When injecting a provider, it must be visible within the module scope (loosely speaking, the containing module) of the class it is being injected into. This can be done by:
@Global()
decoratorProviders can also be defined in a more explicit and imperative form using various custom provider techniques that expose more capabilities of the DI system.
options specifying scope of injectable
Decorator that marks a class as a module.
Modules are used by Nest to organize the application structure into scopes. Controllers and Providers are scoped by the module they are declared in. Modules and their classes (Controllers and Providers) form a graph that determines how Nest performs Dependency Injection (DI).
module configuration metadata
Parameter decorator for an injected dependency marking the dependency as optional.
For example:
constructor(@Optional() @Inject('HTTP_OPTIONS')private readonly httpClient: T) {}
Route handler parameter decorator. Extracts the params
property from the req
object and populates the decorated
parameter with the value of params
. May also apply pipes to the bound
parameter.
For example, extracting all params:
findOne(@Param() params: string[])
For example, extracting a single param:
findOne(@Param('id') id: string)
Route handler parameter decorator. Extracts the params
property from the req
object and populates the decorated
parameter with the value of params
. May also apply pipes to the bound
parameter.
For example, extracting all params:
findOne(@Param() params: string[])
For example, extracting a single param:
findOne(@Param('id') id: string)
one or more pipes - either instances or classes - to apply to the bound parameter.
Route handler parameter decorator. Extracts the params
property from the req
object and populates the decorated
parameter with the value of params
. May also apply pipes to the bound
parameter.
For example, extracting all params:
findOne(@Param() params: string[])
For example, extracting a single param:
findOne(@Param('id') id: string)
name of single property to extract from the req
object
one or more pipes - either instances or classes - to apply to the bound parameter.
Route handler parameter decorator. Extracts the query
property from the req
object and populates the decorated
parameter with the value of query
. May also apply pipes to the bound
query parameter.
For example:
async find(@Query('user') user: string)
Route handler parameter decorator. Extracts the query
property from the req
object and populates the decorated
parameter with the value of query
. May also apply pipes to the bound
query parameter.
For example:
async find(@Query('user') user: string)
one or more pipes to apply to the bound query parameter
Route handler parameter decorator. Extracts the query
property from the req
object and populates the decorated
parameter with the value of query
. May also apply pipes to the bound
query parameter.
For example:
async find(@Query('user') user: string)
name of single property to extract from the query
object
one or more pipes to apply to the bound query parameter
Redirects request to the specified URL.
Route handler method Decorator. Defines a template to be rendered by the controller.
For example: @Render('index')
name of the render engine template file
Route handler parameter decorator. Extracts the Response
object from the underlying platform and populates the decorated
parameter with the value of Response
.
Example: logout(@Response() res)
Decorator that assigns metadata to the class/function using the
specified key
.
Requires two parameters:
key
- a value defining the key under which the metadata is storedvalue
- metadata to be associated with key
This metadata can be reflected using the Reflector
class.
Example: @SetMetadata('roles', ['admin'])
Declares this route as a Server-Sent-Events endpoint
Decorator that binds exception filters to the scope of the controller or method, depending on its context.
When @UseFilters
is used at the controller level, the filter will be
applied to every handler (method) in the controller.
When @UseFilters
is used at the individual handler level, the filter
will apply only to that specific method.
exception filter instance or class, or a list of exception filter instances or classes.
Decorator that binds guards to the scope of the controller or method, depending on its context.
When @UseGuards
is used at the controller level, the guard will be
applied to every handler (method) in the controller.
When @UseGuards
is used at the individual handler level, the guard
will apply only to that specific method.
a single guard instance or class, or a list of guard instances or classes.
Decorator that binds interceptors to the scope of the controller or method, depending on its context.
When @UseInterceptors
is used at the controller level, the interceptor will
be applied to every handler (method) in the controller.
When @UseInterceptors
is used at the individual handler level, the interceptor
will apply only to that specific method.
a single interceptor instance or class, or a list of interceptor instances or classes.
Decorator that binds pipes to the scope of the controller or method, depending on its context.
When @UsePipes
is used at the controller level, the pipe will be
applied to every handler (method) in the controller.
When @UsePipes
is used at the individual handler level, the pipe
will apply only to that specific method.
a single pipe instance or class, or a list of pipe instances or classes.
Function that returns a new decorator that applies all decorators provided by param
Useful to build new decorators (or a decorator factory) encapsulating multiple decorators related with the same feature
one or more decorators (e.g., ApplyGuard(...)
)
Creates a CacheManager Provider.
Create an instance of Axios
The default config for the instance
A new instance of Axios
Defines HTTP route param decorator
Extends object a by mutably adding to it the properties of object b.
The object to be extended
The object to copy properties from
The object to bind function to
The resulting value of object a
Iterate over an Array or an Object invoking a function for each item.
If obj
is an Array callback will be called passing
the value, index, and complete array for each item.
If 'obj' is an Object callback will be called passing the value, key, and complete object for each property.
The object to iterate
The callback to invoke for each item
Calculate output length with padding and bit length
Determine if a value is an Array
The value to test
True if value is an Array, otherwise false
Determine if a value is an ArrayBuffer
The value to test
True if value is an ArrayBuffer, otherwise false
Determine if a value is a view on an ArrayBuffer
The value to test
True if value is a view on an ArrayBuffer, otherwise false
Determine if a value is a Blob
The value to test
True if value is a Blob, otherwise false
Determine if a value is a Buffer
The value to test
True if value is a Buffer, otherwise false
Determine if a value is a Date
The value to test
True if value is a Date, otherwise false
Determine if a value is a File
The value to test
True if value is a File, otherwise false
Determine if a value is a FormData
The value to test
True if value is an FormData, otherwise false
Determine if a value is a Function
True if value is a Function, otherwise false
Determine if a value is a Number
The value to test
True if value is a Number, otherwise false
Determine if a value is an Object
True if value is an Object, otherwise false
Determine if a value is a plain Object
True if value is a plain Object, otherwise false
Determine if we're running in a standard browser environment
This allows axios to run in a web worker, and react-native. Both environments support XMLHttpRequest, but not fully standard globals.
web workers: typeof window -> undefined typeof document -> undefined
react-native: navigator.product -> 'ReactNative' nativescript navigator.product -> 'NativeScript' or 'NS'
Determine if a value is a Stream
The value to test
True if value is a Stream, otherwise false
Determine if a value is a String
True if value is a String, otherwise false
Determine if a value is a URLSearchParams object
The value to test
True if value is a URLSearchParams object, otherwise false
Determine if a value is undefined
True if the value is undefined, otherwise false
Creates an Iterator with advanced chainable operator methods for any Iterable or Iterator
Accepts varargs expecting each argument to be an object, then immutably merges the properties of each object and returns result.
When multiple objects contain the same key the later object in the arguments list will take precedence.
Example:
var result = merge({foo: 123}, {foo: 456});
console.log(result.foo); // outputs 456
Result of all merge properties
Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
with BOM
content value without BOM
Throws a Cancel
if cancellation has been requested.
Trim excess whitespace off the beginning and end of a string
The String to trim
The String freed of excess whitespace
Creates an Iterator that emits pairs of values from the two passed Iterators
A timeout in milliseconds to abort a request. If set to 0 (default) a timeout is not created.
Generated using TypeDoc
Decorator that sets the cache ttl setting the duration for cache expiration.
For example:
@CacheTTL(5)
number set the cache expiration time
Caching