From 0847618506ce5d45cf68feb048ac6344c47ad4fa Mon Sep 17 00:00:00 2001 From: Rolando Santamaria Maso Date: Mon, 26 Jan 2026 14:22:21 +0100 Subject: [PATCH] Rebrand from fast-di to fast-injection --- QUICKSTART.md | 36 ++++++++++---------- README.md | 28 ++++++++-------- SECURITY.md | 10 +++--- benchmarks/README.md | 6 ++-- benchmarks/index.ts | 2 +- bun.lock | 2 +- docs/CNAME | 2 +- docs/index.html | 54 +++++++++++++++--------------- docs/script.js | 8 ++--- examples/01-simple-registration.ts | 2 +- examples/README.md | 4 +-- examples/run-all.ts | 2 +- package.json | 8 ++--- scripts/README.md | 2 +- src/core/container.ts | 12 +++---- 15 files changed, 89 insertions(+), 89 deletions(-) diff --git a/QUICKSTART.md b/QUICKSTART.md index c64f7c0..df10020 100644 --- a/QUICKSTART.md +++ b/QUICKSTART.md @@ -3,7 +3,7 @@ ## Installation ```bash -bun add fast-di +bun add fast-injection ``` ## Basic Usage @@ -11,8 +11,8 @@ bun add fast-di ### 1. Simple Service Registration ```typescript -import { Container } from "fast-di"; -import { singleton } from "fast-di/decorators"; +import { Container } from "fast-injection"; +import { singleton } from "fast-injection/decorators"; @singleton() class Logger { @@ -25,14 +25,14 @@ const container = new Container(); container.register(Logger); // Decorator controls lifetime const logger = container.resolve(Logger); -logger.log("Hello, fast-di!"); +logger.log("Hello, fast-injection!"); ``` ### 2. Dependency Injection with Factories ```typescript -import { Container } from "fast-di"; -import { singleton } from "fast-di/decorators"; +import { Container } from "fast-injection"; +import { singleton } from "fast-injection/decorators"; @singleton() class Database { @@ -68,8 +68,8 @@ console.log(service.getUsers()); ### 3. Scoped Containers (for HTTP requests) ```typescript -import { Container } from "fast-di"; -import { singleton, scoped, inject } from "fast-di/decorators"; +import { Container } from "fast-injection"; +import { singleton, scoped, inject } from "fast-injection/decorators"; @singleton() class Database { @@ -104,7 +104,7 @@ await requestScope.dispose(); Use `getGlobalContainer()` to access a shared container instance across your entire application without passing it around: ```typescript -import { getGlobalContainer, resetGlobalContainer, Lifetime } from "fast-di"; +import { getGlobalContainer, resetGlobalContainer, Lifetime } from "fast-injection"; // Setup at application startup (e.g., in main.ts) function setupContainer() { @@ -175,7 +175,7 @@ await container.dispose(); // Calls onDispose on all services ### 7. Testing with Mocks ```typescript -import { createTestContainer } from "fast-di/testing"; +import { createTestContainer } from "fast-injection/testing"; // In your tests const container = createTestContainer(); @@ -198,7 +198,7 @@ const service = container.resolve(UserService); While decorators are the recommended default, explicit options are useful when: ```typescript -import { Lifetime } from "fast-di"; +import { Lifetime } from "fast-injection"; // Override decorator at registration @singleton() @@ -220,8 +220,8 @@ You can use decorators to control service lifetimes and document your code. **De ### 8. Decorator-Based Lifetimes ```typescript -import { Container } from "fast-di"; -import { singleton, transient, scoped } from "fast-di/decorators"; +import { Container } from "fast-injection"; +import { singleton, transient, scoped } from "fast-injection/decorators"; @singleton() class ConfigService { @@ -267,7 +267,7 @@ console.log(logger1 === logger2); // false ### 8. Using @inject for Interface Tokens ```typescript -import { injectable, inject } from "fast-di/decorators"; +import { injectable, inject } from "fast-injection/decorators"; const ILogger = Symbol("ILogger"); const IDatabase = Symbol("IDatabase"); @@ -325,7 +325,7 @@ await service.getUsers(); ### 9. Decorators Control Lifetimes ```typescript -import { singleton } from "fast-di/decorators"; +import { singleton } from "fast-injection/decorators"; @singleton() class Database { @@ -412,7 +412,7 @@ const service = container.resolve(UserService); } ``` -### Decorator Methods (from "fast-di/decorators") +### Decorator Methods (from "fast-injection/decorators") - `@injectable()` - Mark class as injectable (transient lifetime) - `@singleton()` - Mark class as singleton lifetime @@ -495,7 +495,7 @@ container.registerFactory(UserService, (c) => { }); // Or, with decorators and @inject, no factory is needed: -import { singleton, inject } from "fast-di/decorators"; +import { singleton, inject } from "fast-injection/decorators"; @singleton() class UserService { @@ -588,4 +588,4 @@ container.registerFactory(ServiceA, (c) => { --- -**fast-di** - Built with โค๏ธ by [21no.de](https://21no.de) | [MIT License](LICENSE) +**fast-injection** - Built with โค๏ธ by [21no.de](https://21no.de) | [MIT License](LICENSE) diff --git a/README.md b/README.md index 8d55d32..0f0569c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# fast-di ๐Ÿš€ +# fast-injection ๐Ÿš€ Modern, lightweight TypeScript Dependency Injection optimized for Bun runtime. -[![npm version](https://img.shields.io/npm/v/fast-di)](https://www.npmjs.com/package/fast-di) -[![Bundle Size](https://img.shields.io/badge/bundle%20size-%3C5KB-brightgreen)](https://github.com/21no-de/fast-di) +[![npm version](https://img.shields.io/npm/v/fast-injection)](https://www.npmjs.com/package/fast-injection) +[![Bundle Size](https://img.shields.io/badge/bundle%20size-%3C5KB-brightgreen)](https://github.com/21no-de/fast-injection) [![TypeScript](https://img.shields.io/badge/TypeScript-5.0%2B-blue)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-1.0%2B-orange)](https://bun.sh) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) @@ -24,7 +24,7 @@ Modern, lightweight TypeScript Dependency Injection optimized for Bun runtime. ## Performance -Fast-DI is optimized for speed with minimal overhead. Here are the key performance metrics: +Fast-Injection is optimized for speed with minimal overhead. Here are the key performance metrics: | Operation | Ops/Second | Avg Time | Notes | | -------------------- | ------------- | -------- | -------------------------------- | @@ -59,7 +59,7 @@ Run benchmarks yourself: `bun run bench` ## Installation ```bash -bun add fast-di +bun add fast-injection ``` ## Quick Start @@ -67,8 +67,8 @@ bun add fast-di ### Basic Usage ```typescript -import { Container } from "fast-di"; -import { singleton, inject } from "fast-di/decorators"; +import { Container } from "fast-injection"; +import { singleton, inject } from "fast-injection/decorators"; // Step 1: Define your services // Use @singleton() decorator to mark this class as a singleton @@ -106,7 +106,7 @@ const userService = container.resolve(UserService); ### Lifecycle Hooks (Basic) ```typescript -import { Container } from "fast-di"; +import { Container } from "fast-injection"; class Cache { private store = new Map(); @@ -144,8 +144,8 @@ await c.dispose(); ### Advanced: Multiple Lifetimes ```typescript -import { Container } from "fast-di"; -import { singleton, transient, scoped } from "fast-di/decorators"; +import { Container } from "fast-injection"; +import { singleton, transient, scoped } from "fast-injection/decorators"; // SINGLETON: One instance shared across the entire application // Perfect for: configuration, database connections, loggers @@ -196,8 +196,8 @@ const ctx3 = anotherScope.resolve(RequestContext); ### Using @inject for Constructor Injection ```typescript -import { Container } from "fast-di"; -import { singleton, inject } from "fast-di/decorators"; +import { Container } from "fast-injection"; +import { singleton, inject } from "fast-injection/decorators"; // Step 1: Define your dependencies @singleton() @@ -279,7 +279,7 @@ bun run bench ## Security -Fast-DI includes multiple security enhancements to protect your applications: +Fast-Injection includes multiple security enhancements to protect your applications: ### Token Validation @@ -291,7 +291,7 @@ bun run bench ## Security -Fast-DI implements comprehensive security measures to protect against common vulnerabilities. See [SECURITY.md](SECURITY.md) for detailed information. +Fast-Injection implements comprehensive security measures to protect against common vulnerabilities. See [SECURITY.md](SECURITY.md) for detailed information. **Key Features:** - ๐Ÿ›ก๏ธ **Prototype Pollution Prevention**: Token validation rejects dangerous property names diff --git a/SECURITY.md b/SECURITY.md index 5932fef..68afc03 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,6 +1,6 @@ # Security Enhancements -This document describes the security features and best practices implemented in fast-di to protect against common vulnerabilities. +This document describes the security features and best practices implemented in fast-injection to protect against common vulnerabilities. ## Security Features @@ -77,7 +77,7 @@ const result = await container.resolveAsync("api"); **Solution**: Explicit cleanup function for decorator metadata: ```typescript -import { clearDecoratorMetadata, singleton } from "fast-di/decorators"; +import { clearDecoratorMetadata, singleton } from "fast-injection/decorators"; // Create dynamic service @singleton() @@ -201,7 +201,7 @@ container.register("prototype", Service); // Throws! Always dispose containers to prevent resource leaks: ```typescript -import { singleton } from "fast-di/decorators"; +import { singleton } from "fast-injection/decorators"; @singleton() class DatabaseConnection { @@ -335,7 +335,7 @@ The security test suite includes: ### Not Protected Against -- **Code Injection**: Fast-di does not validate factory function code +- **Code Injection**: The library does not validate factory function code - **Dependency Confusion**: Users must ensure correct service registration - **DoS via Circular Dependencies**: Detected but not prevented (throws error) @@ -355,4 +355,4 @@ The security test suite includes: --- -**fast-di** - Built with โค๏ธ by [21no.de](https://21no.de) +**fast-injection** - Built with โค๏ธ by [21no.de](https://21no.de) diff --git a/benchmarks/README.md b/benchmarks/README.md index ddba4e6..403d40d 100644 --- a/benchmarks/README.md +++ b/benchmarks/README.md @@ -1,6 +1,6 @@ -# Fast-DI Performance Benchmarks +# Fast-Injection Performance Benchmarks -This directory contains comprehensive performance benchmarks for the Fast-DI dependency injection container. +This directory contains comprehensive performance benchmarks for the Fast-Injection dependency injection container. ## Running Benchmarks @@ -202,7 +202,7 @@ The overhead from these protections is minimal (< 0.01ยตs per operation) while e ## Comparison with Other DI Containers -Fast-DI is optimized for Bun and provides: +Fast-Injection is optimized for Bun and provides: - **Ultra-low overhead**: ~0.988ยตs per transient resolution, ~0.037ยตs for singletons - **Excellent singleton performance**: 26.8M ops/sec (explicit), 16.7M ops/sec (decorator) diff --git a/benchmarks/index.ts b/benchmarks/index.ts index 4432058..21e3b4e 100644 --- a/benchmarks/index.ts +++ b/benchmarks/index.ts @@ -561,7 +561,7 @@ async function runComparisonBenchmarks(): Promise { // Main execution async function main(): Promise { - console.log("๐Ÿš€ Fast-DI Performance Benchmarks"); + console.log("๐Ÿš€ Fast-Injection Performance Benchmarks"); console.log(`Running on Bun ${Bun.version}`); console.log(`Platform: ${process.platform} ${process.arch}`); diff --git a/bun.lock b/bun.lock index 4aca806..e430298 100644 --- a/bun.lock +++ b/bun.lock @@ -3,7 +3,7 @@ "configVersion": 1, "workspaces": { "": { - "name": "fast-di", + "name": "fast-injection", "devDependencies": { "@types/bun": "latest", "prettier": "^3.2.4", diff --git a/docs/CNAME b/docs/CNAME index c18620e..d07408e 100644 --- a/docs/CNAME +++ b/docs/CNAME @@ -1 +1 @@ -fast-di.21no.de \ No newline at end of file +fast-injection.21no.de \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 8259da5..2fa6e76 100644 --- a/docs/index.html +++ b/docs/index.html @@ -3,13 +3,13 @@ - fast-di - Modern TypeScript Dependency Injection + fast-injection - Modern TypeScript Dependency Injection - +
-

fast-di

+

fast-injection

Modern TypeScript Dependency Injection

Blazing fast, lightweight DI container optimized for Bun runtime.
@@ -54,7 +54,7 @@

fast-di

- $ bun add fast-di + $ bun add fast-injection