| name | dependency-injection |
| description | Dependency Injection pattern for service definitions, factories, and composition roots. Use when working with packages that use the DI pattern. |
Dependency injection
Some parts of the codebase use the Dependency Injection (DI) pattern. Instead of importing dependencies directly, pass them to the service as parameters. This allows better testability and separation of concerns.
Skill boundaries
Use this skill mainly for packages that directly mention this skill.
Service definition standard
The unified pattern for defining services is as follows.
Define in this order for consistency:
1: Service dependencies
Use the same key (serviceName) everywhere. This is important so Dep, Deps, and composition root wiring stay consistent.
export type ServiceNameDeps = OtherServiceDep | AnotherServiceDep;
2. Service shape:
export type ServiceParams = {
id: string;
};
export type ServiceName = (params: ServiceParams) => ;