@goodie-ts/core
v0.7.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 BeanDefinition[] 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 genericsBeanDefinition<T>— Bean 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)— async factory, topo-sorts and validates the dependency graphctx.get(token)— synchronous lookup (throws for unresolved async beans)ctx.getAsync(token)— always safe for async factoriesctx.getAll(token)— returns all beans registered under a tokenctx.close()— tears down the context
