Simple, Decorated, Pluggable dependency-injection framework for TypeScript applications

Injex makes software architecture more easy & fun by creating a dependency tree between your application modules with a minimal API.

Get StartedView Source

The right way to write TypeScript applications

Use decorators to define, reuse, and link modules and dependencies together.

flare

Simple

Define and reuse modules and dependencies.

settings_input_component

Pluggable

Use or create plugins to manage dependencies.

category

Organized

Better project code organization approach.

For TypeScript

Power up your Node.JS or client-side TypeScript applications.

looks_one

Singleton

Create, inject, and reuse modules as singletons.

build

Factories

Inject class factories to create module instances easily.

account_tree

SOLID Principles

Get the tools to implement SOLID applications.

code

Lazy Modules

Create lazy modules and take control of client-side code splitting.

The fastest way to get started

Quick installation of Injex core and Node.JS/Webpack/Vite runtime.

Injex runtimes are consistent so that you wouldn't notice any change. Full Stack TypeScript development (server/client) at its best.

  • Unopinionated
  • Minimalist API
  • Use decorators to play
  • Flexible with plugins
  • Small size footprint

Checkout the examples page for full examples and use cases.

Install using npm or yarn

npm install --save @injex/core @injex/node

Import and create Injex container.

import { Injex } from "@injex/node";
Injex.create({
rootDirs: [
__dirname
]
}).bootstrap();

Create and define modules using decorators

import { define, singleton, inject, injectAlias, AliasMap } from "@injex/core";
@define()
@singleton()
export class MailService {
@inject() private env: IEnvironment;
@injectAlias("IMailProvider", "Type") private mailProviders: AliasMap<MailProviderType, IMailProvider>;
public send(message: Mail) {
const mailProvider = this.mailProviders[this.env.mailProvider];
mailProvider.send(message);
}
}

Checkout the basic example for a working demo.

add

Injex changes the way you write TypeScript applications. Forever.

Get StartedView Source