@nwire/container-awilix
v0.7.1
Published
Nwire — Awilix-backed Container adapter. Production-grade DI with proper scoping + cradle injection.
Readme
@nwire/container-awilix
Awilix-backed implementation of the
@nwire/containercontract — production default.
What it does
Wraps Awilix so it satisfies Nwire's Container interface. Awilix gives you proper scoping (createScope() is first-class), auto-injection by parameter name (cradle pattern), and a fast lookup path; this adapter exposes that under the standardized four-method shape every Nwire layer composes through.
Install
pnpm add @nwire/container-awilix awilixQuick start
import { AwilixNwireContainer } from "@nwire/container-awilix";
import { asValue, asFunction } from "awilix";
import { createApp } from "@nwire/forge";
const container = new AwilixNwireContainer();
container.register("logger", logger);
container.register("courseStore", () => new MongoCourseStore(db));
const app = createApp("learnflow", { modules, container });API surface
AwilixNwireContainer({ injectionMode?, awilix? })— implementsContainer.injectionModeis"PROXY"(cradle, default) or"CLASSIC".
When to use
Production wires that want first-class lifecycle scoping, cradle-style auto-injection, or circular detection. For tests / small wires the default InMemoryContainer from @nwire/container is usually enough.
Within nwire-app
For developers using this package as part of the Nwire stack — register it via app.use(...) or it auto-wires when you compose createApp({ modules }).
import { createApp } from "@nwire/forge";
const app = createApp({
/* ...config... */
});
// Adapter/plugin wiring happens here when applicable.