Configure Decorator
This file defines the Configure
decorator, which allows you to attach user-defined configuration metadata to a class in the @sodacore/core
library. When applied, the configuration can be resolved and used at runtime, typically during autoloading.
Features
- Attach Configuration: Stores a configuration object as metadata on the decorated class.
- Runtime Access: Enables runtime access to the configuration via metadata utilities.
Usage
typescript
import Configure from './decorator/configure';
@Configure({ apiKey: '12345', debug: true })
export class MyService {
// Class implementation
}
- The configuration object can be any shape and will be attached to the class as metadata.
API
Configure(config: Record<string, any>): ClassDecorator
- config: The configuration object to attach to the class.
- Returns: A class decorator that sets the
user:config
metadata.
Notes
- Use this decorator to provide runtime configuration to classes that require it.
- The configuration can be retrieved using metadata utilities, such as
Utils.getMeta('user', 'config')
.