Constant
@tsed/di
Usage
typescript
import { Constant } from "@tsed/di";
Overview
ts
function Constant<Type = unknown>(expression: string, defaultValue?: Type): PropertyDecorator;
Description
Return value from Configuration.
Example
typescript
import {Env} from "@tsed/core";
import {Constant, Value} from "@tsed/di";
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
}
}