@half0wl/container / Service
Function: Service()
ts
function Service(options?): ClassDecorator;Defined in: decorators.ts:48
Class decorator that marks a class as container-managed.
When trace is enabled, the container will wrap all methods with tracing spans using the configured trace function.
Requires experimentalDecorators: true in tsconfig.json.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | ServiceOptions | Optional configuration for the service |
Returns
ClassDecorator
A class decorator
Example
ts
@Service()
class UserService extends BaseService<ContainerDeps> {
findById(id: string) {
return this.deps.db.users.findUnique({ where: { id } });
}
}
@Service({ trace: true })
class TracedService extends BaseService<ContainerDeps> {
// All methods auto-traced as "TracedService.methodName"
process() { ... }
}