roeibh / injex

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

Home Page:https://www.injex.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Injex Language grade: JavaScript Injex License Node Version TypeScript Version

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.

Installation

Start by installing the core package. This package includes most of the functionality you're going to use when working with the Injex framework.

npm install --save @injex/core

After the core is installed and based on your project, you need to install a runtime container. The runtime container enables modules definition and registration across your application.

You can currently choose between the Node or Webpack runtimes for the server or the client, respectively.

Node Runtime

Create a dependency-injection container inside a Node.JS application.

npm install --save @injex/node

Webpack Runtime

Create a dependency-injection container inside a Webpack bundled client-side application.

npm install --save @injex/webpack

Getting Started

Basic Usage

Create an Injex Node runtime container.

import { Injex } from "@injex/node";

Injex.create({
    rootDirs: [
        "./src"
    ]
}).bootstrap()

Injex will scan all the files and folders recursively and look for Injex modules.

Module definition example:

// src/services/mailService.ts
import { define, singleton, inject } from "@injex/core";

@define()
@singleton()
export class MailService {
    @inject() private mailProvider: IMailProvider;

    public sendMail(mail: Mail) {
        this.mailProvider.send(mail);
    }
}

Since Injex automatically scans all the files and folders inside the rootDirs, this is all you need to do to create an injectable module.

Learn more >>

Plugins

Injex is pluggable, so you can use and create your plugins to enrich your applications.

📦 Env Plugin - Manage environment variables across your application. Docs →

📦 Express Plugin - Use Injex to power up your Express application by creating controllers, better route handlers, and middlewares. Docs →

📦 React Plugin - Use React hooks to inject dependencies into components. Docs →

Learn more about Injex plugins and the plugin anatomy.

Follow Us

Follow us on Twitter or join our live Discord server for more help, ideas, and discussions.

Author

twitter/uditalias
Udi Talias

License

This repository is available under the MIT License.

About

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

https://www.injex.dev

License:MIT License


Languages

Language:TypeScript 81.0%Language:JavaScript 13.3%Language:CSS 5.6%Language:Shell 0.1%