Injets is a TypeScript Dependency Injection library inspired by NestJS that uses reflect-metadata and annotations to make your code more organized.
✏️ Annotations: Use annotations in your module classes to make your dependecy flow easier to understand.
🏢 Singletons and Transient providers: Create singletons just by specifying a single flag, and don't bother when you should instantiate your classes anymore.
Table of Contents
npm i injetsyarn add injets
To start using injets, you first have to create a
root module is simply a starting point for your project, so all
other modules are going to be attached to it.
Here's how you can register a provider on the
// --- hello-world.provider.ts ---// --- app.module.ts ---;
Instantiating the root module
To get your app up and running you first have to instantiate the
To do so, there's a static helper called
This is your entry point:
// --- index.js ---main
Providers are entities that are responsible for executing the logic of your application. You often have to access logic from other parts of your app.
// --- app.module.ts ---;// --- http.provider.ts ---;
Modules are a group of providers, your application must have at least one module (root module).
Structure of a module
A provider can be anything you want to use anywhere in your application, but they are generally used to provide business logic methods for your app.
Structure of a provider
// A provider can have SINGLETON or TRANSIENT scope