0.1.0 • Published 2 years ago
@xprofiler/injection v0.1.0
injection
An IoC implemention for xprofiler.
Usage
Decorator
import { Injectable, Inject } from "@xprofiler/injection";
import { Config } from "./config";
@Injectable()
export class Foo {
@Inject()
private config: Config;
getKmsConfig(@Inject('KMS_KEY') key: string) {
return this.config[key];
}
}
Container
import { Container } from "@xprofiler/injection";
import { Foo, Bar } from "./items";
const container = new Container();
container.set(Foo);
container.set(Bar);
const foo = container.get(Foo);
const bar = container.get(Bar);