injectMany
@tsed/di
Usage
typescript
import { injectMany } from "@tsed/di";Overview
ts
function injectMany<T>(token: string | symbol, opts?: Partial<Pick<InvokeOptions, "useOpts" | "rebuild" | "locals">>): T[];token (
string|symbol): The injection token or type to resolveopts (
Partial<Pick<InvokeOptions): Optional. invocation optionsopts.useOpts (``): Options passed to instance creation
opts.rebuild (``): Whether to rebuild instances
opts.locals (``): Local container overrides
Description
Inject all providers matching a given token type.
Resolves multiple provider instances that share the same type or group token. Useful for getting all providers of a specific category (e.g., all controllers, all middleware).
Usage
typescript
import {injectMany, ProviderType} from "@tsed/di";
// Get all controllers
const controllers = injectMany(ProviderType.CONTROLLER);
// Get all providers of a custom type
const plugins = injectMany(Symbol.for("PLUGIN"));