UNPKG

@nova-ts/core

Version:

A serverside framework used to build scalable application

41 lines (39 loc) 1.39 kB
declare function getAllValueClassTargets(): Function[]; type CombinedDecorator = ClassDecorator & PropertyDecorator; /** * Decorator that injects configuration values from a property source (e.g., .yml, .env) * into class fields or registers the configuration path for the entire class. * * ### Property-level usage: * Injects the specified configuration value directly into the field. * ```ts * class AppConfig { * @Value('server.port') * port: number; * } * ``` * * ### Class-level usage: * Binds the class to a configuration path. All properties in the file under that path * will be mapped to matching fields in the class. * ```ts * @Value('database') * class DatabaseConfig { * host: string; * port: number; * username: string; * password: string; * } * ``` * * ### Notes: * - For class-level usage, ensure that the class is registered as a singleton or component * in the application context to be instantiated and injected where needed. * - Internally uses a configuration loader (like `js-yaml` or `dotenv`) to resolve the values. * - Supports nested property resolution. * * @param path - The key path to the property (e.g., `'server.port'` or `'database'`) * @returns A decorator usable on either classes or class properties. */ declare function Value(path: string): CombinedDecorator; export { Value, getAllValueClassTargets };