Skip to main content
  • npm version
  • minzip size
  • MIT license
  • pr's welcome

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(app.getQuote());
}

Features

  • 🌾 Field injection
  • 🔨 Constructor injection
  • 🔢 Environment variable parsing