Seldszar / dera

Yet another NodeCG plugin for TypeDI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Yet another NodeCG plugin for TypeDI

License:MIT License


Languages

Language:JavaScript 91.4%Language:Shell 8.6%