dera
v1.0.1
Published
Yet another TypeDI extension for NodeCG
Downloads
1
Readme
Dera
Yet another TypeDI extension for NodeCG
This TypeDI extension enable the usage of NodeCG ecosystem in services via decorators.
Install
$ npm install dera
Usage
import { useContainer, InjectNodeCG, InjectReplicant } from "dera";
import { NodeCG, ReplicantServer } from "nodecg/types/server";
import { Container, Service } from "typedi";
@Service()
class HelloModule {
@InjectNodeCG() nodecg!: NodeCG;
@InjectReplicant({ defaultValue: "Spark" }) name!: ReplicantServer<string>;
say(): void {
console.log(`Hello ${this.name.value}!`); // Prints "Hello Spark!"
}
}
export = (nodecg: NodeCG) => {
useContainer(Container, nodecg);
Container.get(HelloModule).say();
};
API
See the TypeScript definition file.
Author
Alexandre Breteau - @0xSeldszar
License
MIT © Alexandre Breteau