@plinthjs/core
v0.1.0
Published
Mason core: the service container, configuration repository, service providers, application kernel, and facades.
Maintainers
Readme
@plinthjs/core
The kernel of Mason: the service container, configuration, service providers,
the application lifecycle, and facades. Depends only on @plinthjs/support.
Phased container (see ADR-0001). This package ships the container surface — the Laravel-shaped API — as a standalone IoC. It is backed by / bridged to NestJS's DI at the Tier-3 HTTP integration point. Nest remains the runtime bet; this only sequences when it's adopted.
What's here
| Export | Mirrors | Notes |
| ------------------------- | ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| Container | Illuminate\Container | bind/singleton/instance/make/build/alias/bound/forget/flush, tagging (tag/tagged), contextual binding (when().needs().give()) |
| Config | Illuminate\Config\Repository | dot-path get/set/has/merge/all |
| parseDotenv / env | the .env loader + env() | parse .env content; coerce true/false/null/empty/numbers |
| ServiceProvider | Illuminate\Support\ServiceProvider | async-capable register() + boot() |
| Application | Foundation\Application | a Container that owns config + the provider lifecycle |
| Facade / createFacade | facades (ADR-0005) | Proxy-backed static-call layer; Facade.swap() for test fakes |
Identifiers are string/symbol tokens or class constructors. JS has no reflection-based
autowiring, so dependencies are wired through factory functions (or build with explicit args).
Usage
import { Application, ServiceProvider, Facade, createFacade } from '@plinthjs/core'
class CacheProvider extends ServiceProvider {
register() {
this.app.singleton('cache', () => new Map())
}
}
const app = new Application({ config: { app: { name: 'Mason' } } })
await app.bootstrapWith([CacheProvider])
// DI (recommended):
const cache = app.make<Map<string, unknown>>('cache')
// Facade (fidelity):
Facade.setContainer(app)
const Cache = createFacade<Map<string, unknown>>('cache')
Cache.set('framework', app.config.get('app.name'))Contextual binding
app.when('photos').needs('disk').give('disk.local')
app.when('videos').needs('disk').give('disk.s3')