Proxy-Based DI
Uses JavaScript Proxies as unique identifiers for dependencies, eliminating the need for string tokens or symbols.
A modern DI framework where the proxy (blob) is the key
npm install @speajus/diblobimport { createBlob, createContainer } from '@speajus/diblob';
// Define your service interface
interface Logger {
log(message: string): void;
}
// Create a blob (proxy) for the service
const logger = createBlob<Logger>('logger', {
name: 'Console Logger',
description: 'Logs messages to the console'
});
// Create a container
const container = createContainer();
// Register the implementation
class ConsoleLogger implements Logger {
log(message: string) {
console.log(message);
}
}
container.register(logger, ConsoleLogger);
// Use the service
logger.log('Hello, Diblob!');The core dependency injection framework.
Model Context Protocol server for diblob containers.
Connect-based gRPC server implementation for diblob containers.
Interactive visualization tool for your dependency graphs.
OpenTelemetry instrumentation for diblob containers.
Unlike traditional DI frameworks that use strings or symbols, Diblob uses JavaScript Proxies as keys. This provides type safety and eliminates naming conflicts.
When you re-register a service, all dependent services are automatically invalidated and re-resolved on next access.
Full support for async factories and dependencies:
container.register(database, async () => {
await connectToDatabase();
return new DatabaseService();
});Automatically inject dependencies via constructor default parameters:
class UserService {
constructor(
private logger = logger,
private database = database
) {}
}Attach rich metadata to blobs and containers:
const userService = createBlob<UserService>('userService', {
name: 'User Service',
description: 'Manages user data',
version: '1.0.0',
tags: ['business', 'core']
});MIT