Skip to content

@noneforge/iocType-safe Dependency Injection

Modern DI container for TypeScript with decorators, modules, and interceptors

Quick Example โ€‹

typescript
import 'reflect-metadata';
import { Container, Injectable, inject } from '@noneforge/ioc';

@Injectable()
class LoggerService {
  log(message: string) {
    console.log(`[LOG] ${message}`);
  }
}

@Injectable()
class UserService {
  private logger = inject(LoggerService);

  createUser(name: string) {
    this.logger.log(`Creating user: ${name}`);
    return { id: 1, name };
  }
}

const container = new Container();
container.addProvider(LoggerService);
container.addProvider(UserService);

const userService = container.get(UserService);
userService.createUser('John');

Released under the MIT License.