# Value Decorator
Module | import { Value } from "@tsed/di" |
---|---|
Source | /packages/di/src/decorators/value.ts |
# Overview
function Value(expression: any, defaultValue?: any): (target: any, propertyKey: string) => void;
# Description
Return value from Configuration.
# Example
import {Env} from "@tsed/core";
import {Constant, Value} from "@tsed/common";
export class MyClass {
@Constant("env")
env: Env;
@Value("swagger.path")
swaggerPath: string;
@Value("swagger.path", "defaultValue")
swaggerPath: string;
constructor() {
console.log(this.swaggerPath) // undefined. Not available on constructor
}
$onInit() {
console.log(this.swaggerPath) // something
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
- Session & cookies
- Passport.js
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- Throw HTTP Exceptions
- Customize 404
- AWS
- Jest
- Seq
- Controllers
- Providers
- Model
- Converters
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing