Decorator
LocalsModule | import { Locals } from "@tsed/common" |
---|---|
Source | /packages/common/src/filters/decorators/locals.ts |
Overview
function Locals(expression?: string | any): Function;
Param | Type | Description |
---|---|---|
expression | string | any | Optional. The path of the property to get. |
Description
Locals return the value from response.locals object.
Example
@Controller('/')
class MyCtrl {
@Get('/')
get(@Locals() locals: any) {
console.log('Entire locals', locals);
}
@Get('/')
get(@Locals('user') user: any) {
console.log('user', user);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
For more information on deserialization see converters page.