npm.io
1.5.2 • Published 6d ago

@frontmcp/di

Licence
Apache-2.0
Version
1.5.2
Deps
0
Size
138 kB
Vulns
0
Weekly
2.5K

@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.

Keywords