npm.io
3.2.0 • Published 4 years ago

ts-injection

Licence
MIT
Version
3.2.0
Deps
1
Size
53 kB
Vulns
0
Weekly
0
Stars
2

ts-injection is an annotation based dependency injection framework written in Typescript for NodeJS apps. It enables building applications that have loosely coupled components.

Show me some code

@Injectable()
class ArnyService {
  public getQuote(): string {
    return "Get to the choppa!";
  }
}

@Injectable()
class ArnyApp {
  @Autowire(ArnyService)
  private service!: ArnyService;

  public getQuote(): string {
    return this.service.getQuote();
  }
}

const container = new InjectionContainer();

function main(): void {
  const app = container.resolve(ArnyApp);
  
  console.log(handler.getQuote());
}

Features

  • Field injection
  • Constructor injection
  • Environment variable parsing

View full documentation

Keywords