@goodie-ts/core
v2.0.0
Published
Runtime dependency injection container for goodie-ts
Readme
@goodie-ts/core
Runtime dependency injection container for goodie-ts.
Install
pnpm add @goodie-ts/coreOverview
This package provides the runtime container that resolves pre-built ComponentDefinition[] arrays generated by @goodie-ts/transformer. No reflection, no scanning — just a fast topological sort and lazy instantiation.
Key Exports
ApplicationContext— DI container withcreate(),get(),getAsync(),getAll(),close()Goodie/GoodieBuilder— Bootstrap builder:Goodie.build(definitions).start()InjectionToken<T>— Typed token for interfaces, primitives, and genericsComponentDefinition<T>— Component descriptor with token, scope, factory, dependencies, and metadatabuildInterceptorChain— AOP runtime: chainsMethodInterceptorinstances around a methodwrapBeforeAdvice/wrapAfterAdvice— AdaptBeforeAdvice/AfterAdviceintoMethodInterceptorMethodInterceptor,InvocationContext— AOP type contracts for interceptors
Usage
import { Goodie } from '@goodie-ts/core';
import { definitions } from './AppContext.generated.js';
const app = await Goodie.build(definitions).start();
const userService = app.context.get(UserService);
// When done:
await app.context.close();API
ApplicationContext.create(defs, options?)— async factory, evaluates conditional rules (@ConditionalOnProperty,@ConditionalOnEnv,@ConditionalOnMissingComponent) at runtime, then topo-sorts and validates the dependency graphctx.get(token)— synchronous lookup (throws for unresolved async components)ctx.getAsync(token)— always safe for async factoriesctx.getAll(token)— returns all components registered under a tokenctx.close()— tears down the context
All missing dependency errors include fuzzy matching suggestions ("Did you mean: UserService?"), requiredBy context, and hints when a component was excluded by a conditional rule.
