@nwire/container 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -23
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -12,24 +12,6 @@ A small `Container` interface (`resolve` / `has` / `register` / `createScope`) p
|
|
|
12
12
|
pnpm add @nwire/container
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
## Standalone use
|
|
16
|
-
|
|
17
|
-
For developers who want a tiny DI seam in any TypeScript app — no Nwire dependency on the rest of the stack. Use `InMemoryContainer` as a typed registry and `createScope()` for per-request isolation.
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
import { InMemoryContainer } from "@nwire/container";
|
|
21
|
-
|
|
22
|
-
const root = new InMemoryContainer();
|
|
23
|
-
root.register("db", () => new PrismaClient());
|
|
24
|
-
|
|
25
|
-
// per-request scope inherits the parent but isolates request-scoped values
|
|
26
|
-
const scope = root.createScope();
|
|
27
|
-
scope.register("user", () => req.user);
|
|
28
|
-
|
|
29
|
-
const db = scope.resolve<PrismaClient>("db"); // falls through to root
|
|
30
|
-
const user = scope.resolve<User>("user"); // local to this scope
|
|
31
|
-
```
|
|
32
|
-
|
|
33
15
|
## Within nwire-app
|
|
34
16
|
|
|
35
17
|
For developers using this package as part of the Nwire stack. Plugins register on the container during `boot`; handlers resolve via `ctx.resolve("key")`. Swap the implementation by passing a different `Container` to `createApp`.
|
|
@@ -49,8 +31,3 @@ const app = createApp("learnflow", { modules, container });
|
|
|
49
31
|
- `Container` — interface every adapter implements.
|
|
50
32
|
- `InMemoryContainer` — `Map`-backed default; good for tests and small wires.
|
|
51
33
|
- `rootContainer` — a pre-built blank `InMemoryContainer` framework layers compose with.
|
|
52
|
-
|
|
53
|
-
## See also
|
|
54
|
-
|
|
55
|
-
- [Architecture sketch §05 — Foundation tier](../../architecture-sketch.html#packages)
|
|
56
|
-
- Sibling packages: [@nwire/container-awilix](../nwire-container-awilix), [@nwire/app](../nwire-app)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nwire/container",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Nwire — DI container contract + InMemory default. Production adapters land as @nwire/container-awilix.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"container",
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
"ioc",
|
|
9
9
|
"nwire"
|
|
10
10
|
],
|
|
11
|
+
"license": "MIT",
|
|
11
12
|
"files": [
|
|
12
13
|
"dist",
|
|
13
|
-
"README.md"
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
14
16
|
],
|
|
15
17
|
"type": "module",
|
|
16
18
|
"main": "./dist/container.js",
|