docs: refresh explainers + adding-a-feature with full binder signature
di-explainer and data-flow-explainer narratives still showed the pre-ADR-014 1-arg bindProductionBlog(config) form. Updated both explainers to (config, tracer, logger, bus, queue), and adjusted the narrative arc so the production-swap step mentions the resolveEventsAndJobs* preamble. adding-a-feature's Step 16 sketch was the same 1-arg shape; replaced with the canonical 5-arg signature and a short note that the bus/queue params are accept-and-forward until gen event consume / gen job generators inject usage at the anchors. Pointer to a real feature's bind-production.ts for the complete reference. Final sweep is clean — no stale (container, config) or 1-arg bindProduction signatures remain in docs/.
This commit is contained in:
@@ -1664,7 +1664,7 @@ footer .colophon {
|
||||
</div>
|
||||
<div class="di-card">
|
||||
<h4>Two binding modes, one symbol.</h4>
|
||||
<p>The <code>BlogModule</code> binds <code>IArticlesRepository</code> to <code>MockArticlesRepository</code> by default — useful at dev/test time. At app boot, <code>bindProductionBlog(config)</code> unbinds the symbol and rebinds it to <code>new ArticlesRepository(config)</code>. Use cases and controllers don't notice — they get whatever the symbol currently resolves to.</p>
|
||||
<p>The <code>BlogModule</code> binds <code>IArticlesRepository</code> to <code>MockArticlesRepository</code> by default — useful at dev/test time. At app boot, <code>bindProductionBlog(config, tracer, logger, bus, queue)</code> unbinds the symbol and rebinds it to <code>new ArticlesRepository(config, tracer, logger)</code>. Use cases and controllers don't notice — they get whatever the symbol currently resolves to.</p>
|
||||
<p>This is also why the boundary stays clean: features don't import <code>core-cms</code>; the app passes the Payload config in.</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1773,7 +1773,7 @@ footer .colophon {
|
||||
|
||||
<p style="margin-top: 32px;"><strong>The mock is reached from two directions.</strong> Both are legitimate, neither is "the test version":</p>
|
||||
<ol class="role-jobs">
|
||||
<li><strong>By the DI container at runtime.</strong> <code>BlogModule</code> binds <code>IArticlesRepository</code> to <code>MockArticlesRepository</code> at module-load time. Anything resolving that symbol — use cases, controllers, tRPC procedures, the dev server — gets the mock until <code>bindProductionBlog(config)</code> swaps it for the real Payload-backed one. See §03.</li>
|
||||
<li><strong>By the DI container at runtime.</strong> <code>BlogModule</code> binds <code>IArticlesRepository</code> to <code>MockArticlesRepository</code> at module-load time. Anything resolving that symbol — use cases, controllers, tRPC procedures, the dev server — gets the mock until <code>bindProductionBlog(config, tracer, logger, bus, queue)</code> swaps it for the real Payload-backed one. See §03.</li>
|
||||
<li><strong>By tests, via direct construction.</strong> Unit tests skip the container entirely. They construct the mock with <code>new MockArticlesRepository()</code> and pass it directly into the use-case factory function. Same class, different consumer — just a closure with a fake repo.</li>
|
||||
</ol>
|
||||
|
||||
@@ -1786,7 +1786,7 @@ footer .colophon {
|
||||
<details class="cf-detail">
|
||||
<summary>show: the mock as DI binding (in module.ts)</summary>
|
||||
<div class="detail-body">
|
||||
<p>This is from <code>packages/blog/src/di/module.ts</code> — the very first binding in the module is the mock. Everything downstream (use cases, controllers) resolves through this default. <code>bindProductionBlog(config)</code> later replaces only this one line at app boot — use case + controller bindings stay put.</p>
|
||||
<p>This is from <code>packages/blog/src/di/module.ts</code> — the very first binding in the module is the mock. Everything downstream (use cases, controllers) resolves through this default. <code>bindProductionBlog(config, tracer, logger, bus, queue)</code> later replaces only this one line at app boot — use case + controller bindings stay put.</p>
|
||||
<pre class="code" data-lang="typescript // packages/blog/src/di/module.ts"><span class="k">export const</span> <span class="n">BlogModule</span> = <span class="k">new</span> <span class="t">ContainerModule</span>((<span class="n">bind</span>) => {
|
||||
<span class="c">// 1) Mock is the DEFAULT binding for the repo symbol.</span>
|
||||
<span class="c">// Dev server, unit tests, storybook all resolve to this.</span>
|
||||
|
||||
Reference in New Issue
Block a user