Service Decorator
This file defines the Service
decorator, which is used to mark classes as services in the @sodacore/core
library. It sets the necessary metadata for the class to be recognized and managed as a service by the autowiring system.
Features
- Service Registration: Marks a class as a service for dependency injection and autowiring.
- Metadata Management: Stores the service type in the class metadata for later discovery.
Usage
typescript
import Service from './decorator/service';
@Service()
export class MyService extends BaseService implements IService {
// Service implementation
}
- Use
@Service()
on any class you want to register as a service. - It is recommended to extend
BaseService
and implement theIService
interface for consistency.
API
Service(): ClassDecorator
- Returns: A class decorator that sets the
type
metadata to'service'
for autowiring.
Notes
- Designed for use with the autowiring and dependency injection system in
@sodacore/core
. - Ensure your service classes extend
BaseService
and implement theIService
interface for best practices.