docs: BindContext binder shape across architecture + per-feature AGENTS
This commit is contained in:
60
AGENTS.md
60
AGENTS.md
@@ -320,36 +320,52 @@ Each app (`web-next`, `web-tanstack`, `cms`) imports both binders per feature an
|
||||
|
||||
```typescript
|
||||
// apps/web-next/src/server/bind-production.ts
|
||||
import { bindProductionBlog } from "@repo/blog/di/bind-production";
|
||||
import { bindProductionAuth } from "@repo/auth/di/bind-production";
|
||||
import { bindProductionMarketingPages } from "@repo/marketing-pages/di/bind-production";
|
||||
import { bindProductionNavigation } from "@repo/navigation/di/bind-production";
|
||||
import { bindProductionMedia } from "@repo/media/di/bind-production";
|
||||
import { bindDevSeedBlog } from "@repo/blog/di/bind-dev-seed";
|
||||
import { bindDevSeedAuth } from "@repo/auth/di/bind-dev-seed";
|
||||
import { bindDevSeedMarketingPages } from "@repo/marketing-pages/di/bind-dev-seed";
|
||||
import { bindDevSeedNavigation } from "@repo/navigation/di/bind-dev-seed";
|
||||
import { bindDevSeedMedia } from "@repo/media/di/bind-dev-seed";
|
||||
import config from "@repo/core-cms";
|
||||
import type { BindProductionContext, BindContext } from "@repo/core-shared/di";
|
||||
import type { IEventBus } from "@repo/core-events";
|
||||
import type { IRealtimeBroadcaster, IRealtimeHandlerRegistry } from "@repo/core-realtime";
|
||||
|
||||
export async function bindAll(): Promise<void> {
|
||||
if (process.env.USE_DEV_SEED === "true") return bindAllDevSeed();
|
||||
if (process.env.NODE_ENV === "production") return bindAllProduction();
|
||||
return bindAllDevSeed();
|
||||
export async function bindAllProduction(deps: BindAllDeps): Promise<void> {
|
||||
const { tracer, logger } = resolveInstrumentation();
|
||||
const { bus, queue } = await resolveEventsAndJobsProduction();
|
||||
const resolvedConfig = await config;
|
||||
const { realtime, realtimeRegistry } = deps;
|
||||
|
||||
const ctx: BindProductionContext<IEventBus, IRealtimeBroadcaster, IRealtimeHandlerRegistry> = {
|
||||
config: resolvedConfig,
|
||||
tracer,
|
||||
logger,
|
||||
bus,
|
||||
queue,
|
||||
realtime,
|
||||
realtimeRegistry,
|
||||
};
|
||||
|
||||
bindProductionAuth(ctx);
|
||||
bindProductionBlog(ctx);
|
||||
bindProductionMarketingPages(ctx);
|
||||
bindProductionNavigation(ctx);
|
||||
bindProductionMedia(ctx);
|
||||
}
|
||||
|
||||
export async function bindAllProduction(): Promise<void> {
|
||||
const resolvedConfig = await config;
|
||||
bindProductionAuth(resolvedConfig);
|
||||
bindProductionBlog(resolvedConfig);
|
||||
bindProductionMarketingPages(resolvedConfig);
|
||||
bindProductionNavigation(resolvedConfig);
|
||||
bindProductionMedia(resolvedConfig);
|
||||
export async function bindAllDevSeed(deps: BindAllDeps): Promise<void> {
|
||||
const { tracer, logger } = resolveInstrumentation();
|
||||
const { bus, queue } = resolveEventsAndJobsDevSeed();
|
||||
const { realtime, realtimeRegistry } = deps;
|
||||
|
||||
const ctx: BindContext<IEventBus, IRealtimeBroadcaster, IRealtimeHandlerRegistry> = {
|
||||
tracer, logger, bus, queue, realtime, realtimeRegistry,
|
||||
};
|
||||
|
||||
await bindDevSeedAuth(ctx);
|
||||
await bindDevSeedBlog(ctx);
|
||||
// ... (same for marketing-pages, navigation, media)
|
||||
}
|
||||
```
|
||||
|
||||
Actual function names: `bindProductionAuth`, `bindProductionBlog`, `bindProductionMarketingPages`, `bindProductionNavigation`, `bindProductionMedia`.
|
||||
|
||||
Each feature binder signature is `(ctx: BindProductionContext): void` for production and `(ctx: BindContext): Promise<void>` for dev-seed. Required ctx fields: `tracer`, `logger`. Production-only: `config`. Optional: `bus`, `queue`, `realtime`, `realtimeRegistry`.
|
||||
|
||||
---
|
||||
|
||||
### Cross-feature events and background jobs (Plan 10, ADR-015)
|
||||
|
||||
Reference in New Issue
Block a user