refactor(auth): migrate use-case binders to wireUseCase

Replace inline withSpan + withCapture blocks for signIn, signUp, and
signOut use cases in both bind-production.ts and bind-dev-seed.ts with
wireUseCase calls. Removes 27 lines of boilerplate per binder file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-13 17:51:16 +00:00
parent e08e0a10c0
commit 88b41798d6
3 changed files with 81 additions and 102 deletions

View File

@@ -6,7 +6,10 @@ import {
type ILogger,
} from "@repo/core-shared/instrumentation";
import type { BindContext } from "@repo/core-shared/di";
import { assertFeatureConformance } from "@repo/core-shared/conformance";
import {
assertFeatureConformance,
wireUseCase,
} from "@repo/core-shared/conformance";
import { authManifest } from "../feature.manifest.js";
import { authContainer } from "./container.js";
import { AUTH_SYMBOLS } from "./symbols.js";
@@ -69,55 +72,49 @@ export async function bindDevSeedAuth(ctx: BindContext): Promise<void> {
AUTH_SYMBOLS.IAuthenticationService,
);
// Wrap use cases + controllers identically to bind-production
const wrappedSignIn = withSpan(
// Use cases
const wrappedSignIn = wireUseCase({
container: authContainer,
symbol: AUTH_SYMBOLS.ISignInUseCase,
factory: signInUseCase,
deps: [repo, authService],
feature: "auth",
layer: "use-case",
name: "signIn",
tracer,
{ name: "auth.signIn", op: "use-case" },
withCapture(
logger,
{ feature: "auth", layer: "use-case", name: "auth.signIn" },
signInUseCase(repo, authService),
),
);
const wrappedSignUp = withSpan(
logger,
});
const wrappedSignUp = wireUseCase({
container: authContainer,
symbol: AUTH_SYMBOLS.ISignUpUseCase,
factory: signUpUseCase,
deps: [repo, authService, bus],
feature: "auth",
layer: "use-case",
name: "signUp",
tracer,
{ name: "auth.signUp", op: "use-case" },
withCapture(
logger,
{ feature: "auth", layer: "use-case", name: "auth.signUp" },
signUpUseCase(repo, authService, bus),
),
);
const wrappedSignOut = withSpan(
logger,
});
const wrappedSignOut = wireUseCase({
container: authContainer,
symbol: AUTH_SYMBOLS.ISignOutUseCase,
factory: signOutUseCase,
deps: [authService],
feature: "auth",
layer: "use-case",
name: "signOut",
tracer,
{ name: "auth.signOut", op: "use-case" },
withCapture(
logger,
{ feature: "auth", layer: "use-case", name: "auth.signOut" },
signOutUseCase(authService),
),
);
logger,
});
// Controllers
for (const sym of [
AUTH_SYMBOLS.ISignInUseCase,
AUTH_SYMBOLS.ISignUpUseCase,
AUTH_SYMBOLS.ISignOutUseCase,
AUTH_SYMBOLS.ISignInController,
AUTH_SYMBOLS.ISignUpController,
AUTH_SYMBOLS.ISignOutController,
]) {
if (authContainer.isBound(sym)) authContainer.unbind(sym);
}
authContainer
.bind(AUTH_SYMBOLS.ISignInUseCase)
.toConstantValue(wrappedSignIn);
authContainer
.bind(AUTH_SYMBOLS.ISignUpUseCase)
.toConstantValue(wrappedSignUp);
authContainer
.bind(AUTH_SYMBOLS.ISignOutUseCase)
.toConstantValue(wrappedSignOut);
authContainer
.bind(AUTH_SYMBOLS.ISignInController)
.toConstantValue(