JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2131
  • Score
    100M100P100Q111126F
  • License Apache-2.0

Generic dependency injection container and registry utilities for TypeScript applications

Package Exports

  • @frontmcp/di
  • @frontmcp/di/esm
  • @frontmcp/di/package.json

Readme

@frontmcp/di

Dependency injection container and registry utilities for FrontMCP.

NPM

Internal package. Used by @frontmcp/sdk — most users do not need to install this directly.

Install

npm install @frontmcp/di reflect-metadata zod

Features

  • Type-safe DI — class tokens with configurable prefixes (docs)
  • Scoped providers — GLOBAL and CONTEXT scopes
  • Hierarchical registries — parent/child container adoption
  • Indexed lookups — O(1) registry queries via IndexedRegistry
  • Change events — subscribe to registry mutations
  • Token factorycreateTokenFactory({ prefix }) for Symbol-based tokens

Quick Example

import 'reflect-metadata';
import { DiContainer, createTokenFactory, ProviderScope } from '@frontmcp/di';

const tokens = createTokenFactory({ prefix: 'MyApp' });

class DatabaseService {
  static metadata = { name: 'Database', scope: ProviderScope.GLOBAL };
}

const container = new DiContainer([DatabaseService]);
await container.ready;
const db = container.get(DatabaseService);

Docs

Topic Link
Providers & DI Providers

License

Apache-2.0 — see LICENSE.