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:
@@ -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(),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user