feat(auth): bind binders accept (realtime, realtimeRegistry) params
Extend bindProductionAuth and bindDevSeedAuth to 7-arg signatures. Fix RecordingRealtimeBroadcaster scope type to structurally match ChannelScope. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import "reflect-metadata";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { NoopTracer, NoopLogger } from "@repo/core-shared/instrumentation";
|
||||
import { RecordingEventBus, RecordingJobQueue } from "@repo/core-testing/instrumentation";
|
||||
import { RecordingEventBus, RecordingJobQueue, RecordingRealtimeBroadcaster } from "@repo/core-testing/instrumentation";
|
||||
import { RealtimeHandlerRegistry } from "@repo/core-realtime";
|
||||
import { bindDevSeedAuth } from "@/di/bind-dev-seed";
|
||||
import { authContainer } from "@/di/container";
|
||||
import { AUTH_SYMBOLS } from "@/di/symbols";
|
||||
@@ -32,7 +33,7 @@ describe("bindDevSeedAuth", () => {
|
||||
});
|
||||
|
||||
it("populates the repository with the dev users", async () => {
|
||||
await bindDevSeedAuth(noop.tracer, noop.logger, new RecordingEventBus(), new RecordingJobQueue());
|
||||
await bindDevSeedAuth(noop.tracer, noop.logger, new RecordingEventBus(), new RecordingJobQueue(), new RecordingRealtimeBroadcaster(), new RealtimeHandlerRegistry());
|
||||
|
||||
const repo = authContainer.get<IUsersRepository>(
|
||||
AUTH_SYMBOLS.IUsersRepository,
|
||||
@@ -45,7 +46,7 @@ describe("bindDevSeedAuth", () => {
|
||||
});
|
||||
|
||||
it("seeds alice reachable by username", async () => {
|
||||
await bindDevSeedAuth(noop.tracer, noop.logger, new RecordingEventBus(), new RecordingJobQueue());
|
||||
await bindDevSeedAuth(noop.tracer, noop.logger, new RecordingEventBus(), new RecordingJobQueue(), new RecordingRealtimeBroadcaster(), new RealtimeHandlerRegistry());
|
||||
|
||||
const repo = authContainer.get<IUsersRepository>(
|
||||
AUTH_SYMBOLS.IUsersRepository,
|
||||
@@ -58,13 +59,13 @@ describe("bindDevSeedAuth", () => {
|
||||
});
|
||||
|
||||
it("is idempotent — calling twice rebuilds a fresh populated repo", async () => {
|
||||
await bindDevSeedAuth(noop.tracer, noop.logger, new RecordingEventBus(), new RecordingJobQueue());
|
||||
await bindDevSeedAuth(noop.tracer, noop.logger, new RecordingEventBus(), new RecordingJobQueue(), new RecordingRealtimeBroadcaster(), new RealtimeHandlerRegistry());
|
||||
const before = authContainer.get<IUsersRepository>(
|
||||
AUTH_SYMBOLS.IUsersRepository,
|
||||
);
|
||||
const beforeAlice = await before.getUserByUsername("alice");
|
||||
|
||||
await bindDevSeedAuth(noop.tracer, noop.logger, new RecordingEventBus(), new RecordingJobQueue());
|
||||
await bindDevSeedAuth(noop.tracer, noop.logger, new RecordingEventBus(), new RecordingJobQueue(), new RecordingRealtimeBroadcaster(), new RealtimeHandlerRegistry());
|
||||
const after = authContainer.get<IUsersRepository>(
|
||||
AUTH_SYMBOLS.IUsersRepository,
|
||||
);
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
type ILogger,
|
||||
} from "@repo/core-shared/instrumentation";
|
||||
import type { IEventBus } from "@repo/core-events";
|
||||
import type { IRealtimeBroadcaster, IRealtimeHandlerRegistry } from "@repo/core-realtime";
|
||||
import type { IJobQueue } from "@repo/core-shared/jobs";
|
||||
import { authContainer } from "./container.js";
|
||||
import { AUTH_SYMBOLS } from "./symbols.js";
|
||||
@@ -38,6 +39,8 @@ export async function bindDevSeedAuth(
|
||||
logger: ILogger,
|
||||
bus: IEventBus,
|
||||
queue: IJobQueue,
|
||||
realtime: IRealtimeBroadcaster,
|
||||
realtimeRegistry: IRealtimeHandlerRegistry,
|
||||
): Promise<void> {
|
||||
// Bind shared instrumentation into feature container
|
||||
if (authContainer.isBound(INSTRUMENTATION_SYMBOLS.TRACER)) {
|
||||
@@ -151,6 +154,8 @@ export async function bindDevSeedAuth(
|
||||
// output at the <gen:event-handlers> / <gen:jobs> anchors below.
|
||||
void bus;
|
||||
void queue;
|
||||
void realtime;
|
||||
void realtimeRegistry;
|
||||
// <gen:event-handlers>
|
||||
// <gen:jobs>
|
||||
// <gen:realtime-handlers>
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
type ILogger,
|
||||
} from "@repo/core-shared/instrumentation";
|
||||
import type { IEventBus } from "@repo/core-events";
|
||||
import type { IRealtimeBroadcaster, IRealtimeHandlerRegistry } from "@repo/core-realtime";
|
||||
import type { IJobQueue } from "@repo/core-shared/jobs";
|
||||
import { authContainer } from "./container";
|
||||
import { AUTH_SYMBOLS } from "./symbols";
|
||||
@@ -29,6 +30,8 @@ export function bindProductionAuth(
|
||||
logger: ILogger,
|
||||
bus: IEventBus,
|
||||
queue: IJobQueue,
|
||||
realtime: IRealtimeBroadcaster,
|
||||
realtimeRegistry: IRealtimeHandlerRegistry,
|
||||
): void {
|
||||
if (bound) return;
|
||||
bound = true;
|
||||
@@ -149,6 +152,8 @@ export function bindProductionAuth(
|
||||
// output at the <gen:event-handlers> / <gen:jobs> anchors below.
|
||||
void bus;
|
||||
void queue;
|
||||
void realtime;
|
||||
void realtimeRegistry;
|
||||
// <gen:event-handlers>
|
||||
// <gen:jobs>
|
||||
// <gen:realtime-handlers>
|
||||
|
||||
Reference in New Issue
Block a user