Dependency Injection is the foundation of testable, loosely-coupled backend code. When classes resolve their own dependencies — by callingDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ronaldjdev/forge/llms.txt
Use this file to discover all available pages before exploring further.
container.resolve() mid-logic, or by instantiating collaborators with new — they become impossible to unit-test without spinning up the full runtime, and the hidden coupling they create is invisible to static analysis and architectural audits. forge temper automates the remediation: it walks your project, identifies classes that violate DI discipline, and applies the correct injection pattern for your active technology profile — whether that is tsyringe decorators, NestJS’s built-in DI system, or manual constructor injection.
Usage
What temper Does
temper adapts its behaviour to the DI strategy associated with your active technology profile (detected by forge profile):
- tsyringe profiles
- Manual DI profiles
- NestJS profiles
Applies to:
express-mongodb, express-prisma, express-drizzle, and fastify-prisma profiles that use tsyringe.- Adds
@injectable()to every class that has injected dependencies - Adds
@inject(TOKEN)to each constructor parameter, using class tokens — never plain strings - Removes
container.resolve()calls from use cases, domain objects, and adapters (resolving is only allowed in bootstrap files such asapp.tsor routes)
DI Rules Enforced
Regardless of profile,temper enforces these universal rules:
| Rule | Severity |
|---|---|
| Always use constructor injection | ERROR |
No service locators (container.resolve() outside bootstrap) | ERROR |
| No global singletons shared across features | WARNING |
No new Dependency() inside injected classes | WARNING |
What is prohibited
- ❌
container.resolve()inside use cases, entities, or adapters - ❌
new UseCase(dep1, dep2)in features that use a DI container - ❌ Importing
tsyringein domain files - ❌ Mixing manual DI and container DI within the same feature
temper detects your active technology profile automatically via forge profile. If the detected profile does not match your intended DI strategy, run forge profile first to confirm it and adjust if necessary.