import 'reflect-metadata';
import { ContainerBuilder, Service } from 'diod';
@Service()
export class ServiceOne {
constructor(
private readonly dep1: ServiceTwo,
private readonly dep2: ServiceThree
) {}
}
@Service()
export class ServiceTwo {
constructor(private readonly dep1: ServiceFour) {}
}
@Service()
export class ServiceThree {}
@Service()
export class ServiceFour {}
const builder = new ContainerBuilder();
builder.registerAndUse(ServiceOne);
builder.registerAndUse(ServiceTwo);
builder.registerAndUse(ServiceThree);
builder.registerAndUse(ServiceFour);
const container = builder.build();
const serviceOne = container.get(ServiceOne);
const serviceTwo = container.get(ServiceTwo);
const serviceThree = container.get(ServiceThree);
const serviceFour = container.get(ServiceFour);
console.log({ serviceOne, serviceTwo, serviceThree, serviceFour });
throw new Error(`Service not decorated: ${[...parents, target.name].join(" -> ")}`);
Error: Service not decorated: ServiceOne
at getDependenciesFromDecoratedServiceOrThrow
...