geoffsee/di-framework
A lightweight, type-safe Dependency Injection framework for TypeScript using decorators. This framework automatically manages service instantiation, dependency resolution, and lifecycle management.
Features
Zero Dependencies: No external dependencies required. Works with SWC and TypeScript's native decorator support.
Type-Safe: Full TypeScript support with type inference for all injected dependencies.
Automatic Resolution: Dependencies are automatically resolved and injected.
Lifecycle Management: Built-in support for singleton and transient service lifecycles.
Factory Functions: Register services using factory functions for complex initialization.
Error Detection: Detects circular dependencies and unregistered services at runtime.
Testing Support: Easy to test with mock service registration.
Why Use This Framework?
Traditional dependency injection requires manual service instantiation and wiring, which becomes error-prone and difficult to maintain as your application grows. This framework eliminates that complexity:
Without DI Framework:
With DI Framework:
Benefits:
No manual service instantiation
No manual dependency wiring
Automatic singleton management
Type-safe dependency resolution
Easier to test (mock services simply by registering test implementations)
Scales better as services grow
Quick Example
Next Steps
Installation - Set up the framework in your project
Quick Start - Learn the basics with simple examples
API Reference - Complete API documentation
Advanced Usage - Learn advanced patterns and techniques