feat(auth): signUp publishes userSignedUpEvent

signUpUseCase now takes an IEventBus and publishes userSignedUpEvent
after creating the user (synthesizing email from username since auth
is username-based). Use case mocks-default in module.ts get a fresh
InMemoryEventBus per resolution; bind-production / bind-dev-seed wire
the shared bus passed by bindAll. Tests updated to inject
RecordingEventBus, including a new test that asserts publish on
success and silence on failure.
This commit is contained in:
2026-05-08 16:28:21 +02:00
parent 7f63adf740
commit c1b8a7e434
7 changed files with 67 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
import { ContainerModule, type interfaces } from "inversify";
import { InMemoryEventBus } from "@repo/core-events";
import type { IUsersRepository } from "../application/repositories/users.repository.interface";
import type { IAuthenticationService } from "../application/services/authentication.service.interface";
@@ -44,9 +45,13 @@ export const AuthModule = new ContainerModule((bind: interfaces.Bind) => {
);
bind<ISignUpUseCase>(AUTH_SYMBOLS.ISignUpUseCase).toDynamicValue((ctx) =>
// Default fallback uses a fresh InMemoryEventBus — real cross-feature
// wiring runs through bindProductionAuth / bindDevSeedAuth where the
// bindAll() dispatcher passes a shared bus instance.
signUpUseCase(
ctx.container.get<IUsersRepository>(AUTH_SYMBOLS.IUsersRepository),
ctx.container.get<IAuthenticationService>(AUTH_SYMBOLS.IAuthenticationService),
new InMemoryEventBus(),
),
);