@hermandev/dilite
Version:
Simple and lightweight Dependency Injection container for TypeScript / Next.js apps
13 lines (12 loc) • 430 B
JavaScript
import { globalRegistry, tokenRegistry } from "../core/registry";
/** Decorator to mark a class as injectable */
export function Injectable(options) {
const deps = options?.deps ?? [];
const scope = options?.scope ?? "singleton";
const token = options?.token;
return function (target) {
globalRegistry.set(target, { deps, scope });
if (token)
tokenRegistry.set(token, target);
};
}