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:
@@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"generatedAt": "2026-05-13T14:38:41.601Z",
|
"generatedAt": "2026-05-13T17:51:01.137Z",
|
||||||
"commit": "6428f10",
|
"commit": "e08e0a1",
|
||||||
"repo": {
|
"repo": {
|
||||||
"statements": 95.87,
|
"statements": 95.86,
|
||||||
"branches": 88.91,
|
"branches": 88.91,
|
||||||
"functions": 100,
|
"functions": 100,
|
||||||
"lines": 95.87,
|
"lines": 95.86,
|
||||||
"counts": {
|
"counts": {
|
||||||
"lf": 3123,
|
"lf": 3117,
|
||||||
"lh": 2994,
|
"lh": 2988,
|
||||||
"brf": 487,
|
"brf": 487,
|
||||||
"brh": 433,
|
"brh": 433,
|
||||||
"fnf": 142,
|
"fnf": 142,
|
||||||
@@ -17,13 +17,13 @@
|
|||||||
},
|
},
|
||||||
"byPackage": {
|
"byPackage": {
|
||||||
"@repo/auth": {
|
"@repo/auth": {
|
||||||
"statements": 93.85,
|
"statements": 93.81,
|
||||||
"branches": 90.82,
|
"branches": 90.82,
|
||||||
"functions": 100,
|
"functions": 100,
|
||||||
"lines": 93.85,
|
"lines": 93.81,
|
||||||
"counts": {
|
"counts": {
|
||||||
"lf": 797,
|
"lf": 791,
|
||||||
"lh": 748,
|
"lh": 742,
|
||||||
"brf": 98,
|
"brf": 98,
|
||||||
"brh": 89,
|
"brh": 89,
|
||||||
"fnf": 44,
|
"fnf": 44,
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import {
|
|||||||
type ILogger,
|
type ILogger,
|
||||||
} from "@repo/core-shared/instrumentation";
|
} from "@repo/core-shared/instrumentation";
|
||||||
import type { BindContext } from "@repo/core-shared/di";
|
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 { authManifest } from "../feature.manifest.js";
|
||||||
import { authContainer } from "./container.js";
|
import { authContainer } from "./container.js";
|
||||||
import { AUTH_SYMBOLS } from "./symbols.js";
|
import { AUTH_SYMBOLS } from "./symbols.js";
|
||||||
@@ -69,55 +72,49 @@ export async function bindDevSeedAuth(ctx: BindContext): Promise<void> {
|
|||||||
AUTH_SYMBOLS.IAuthenticationService,
|
AUTH_SYMBOLS.IAuthenticationService,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Wrap use cases + controllers identically to bind-production
|
// Use cases
|
||||||
const wrappedSignIn = withSpan(
|
const wrappedSignIn = wireUseCase({
|
||||||
|
container: authContainer,
|
||||||
|
symbol: AUTH_SYMBOLS.ISignInUseCase,
|
||||||
|
factory: signInUseCase,
|
||||||
|
deps: [repo, authService],
|
||||||
|
feature: "auth",
|
||||||
|
layer: "use-case",
|
||||||
|
name: "signIn",
|
||||||
tracer,
|
tracer,
|
||||||
{ name: "auth.signIn", op: "use-case" },
|
logger,
|
||||||
withCapture(
|
});
|
||||||
logger,
|
const wrappedSignUp = wireUseCase({
|
||||||
{ feature: "auth", layer: "use-case", name: "auth.signIn" },
|
container: authContainer,
|
||||||
signInUseCase(repo, authService),
|
symbol: AUTH_SYMBOLS.ISignUpUseCase,
|
||||||
),
|
factory: signUpUseCase,
|
||||||
);
|
deps: [repo, authService, bus],
|
||||||
const wrappedSignUp = withSpan(
|
feature: "auth",
|
||||||
|
layer: "use-case",
|
||||||
|
name: "signUp",
|
||||||
tracer,
|
tracer,
|
||||||
{ name: "auth.signUp", op: "use-case" },
|
logger,
|
||||||
withCapture(
|
});
|
||||||
logger,
|
const wrappedSignOut = wireUseCase({
|
||||||
{ feature: "auth", layer: "use-case", name: "auth.signUp" },
|
container: authContainer,
|
||||||
signUpUseCase(repo, authService, bus),
|
symbol: AUTH_SYMBOLS.ISignOutUseCase,
|
||||||
),
|
factory: signOutUseCase,
|
||||||
);
|
deps: [authService],
|
||||||
const wrappedSignOut = withSpan(
|
feature: "auth",
|
||||||
|
layer: "use-case",
|
||||||
|
name: "signOut",
|
||||||
tracer,
|
tracer,
|
||||||
{ name: "auth.signOut", op: "use-case" },
|
logger,
|
||||||
withCapture(
|
});
|
||||||
logger,
|
|
||||||
{ feature: "auth", layer: "use-case", name: "auth.signOut" },
|
|
||||||
signOutUseCase(authService),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
|
// Controllers
|
||||||
for (const sym of [
|
for (const sym of [
|
||||||
AUTH_SYMBOLS.ISignInUseCase,
|
|
||||||
AUTH_SYMBOLS.ISignUpUseCase,
|
|
||||||
AUTH_SYMBOLS.ISignOutUseCase,
|
|
||||||
AUTH_SYMBOLS.ISignInController,
|
AUTH_SYMBOLS.ISignInController,
|
||||||
AUTH_SYMBOLS.ISignUpController,
|
AUTH_SYMBOLS.ISignUpController,
|
||||||
AUTH_SYMBOLS.ISignOutController,
|
AUTH_SYMBOLS.ISignOutController,
|
||||||
]) {
|
]) {
|
||||||
if (authContainer.isBound(sym)) authContainer.unbind(sym);
|
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
|
authContainer
|
||||||
.bind(AUTH_SYMBOLS.ISignInController)
|
.bind(AUTH_SYMBOLS.ISignInController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
|
|||||||
@@ -6,14 +6,11 @@ import {
|
|||||||
type ILogger,
|
type ILogger,
|
||||||
} from "@repo/core-shared/instrumentation";
|
} from "@repo/core-shared/instrumentation";
|
||||||
import type { BindProductionContext } from "@repo/core-shared/di";
|
import type { BindProductionContext } from "@repo/core-shared/di";
|
||||||
import { assertFeatureConformance } from "@repo/core-shared/conformance";
|
import {
|
||||||
import type { ProductionUseCase } from "@repo/core-shared/conformance";
|
assertFeatureConformance,
|
||||||
|
wireUseCase,
|
||||||
|
} from "@repo/core-shared/conformance";
|
||||||
import { authManifest } from "../feature.manifest";
|
import { authManifest } from "../feature.manifest";
|
||||||
import type { AuthManifest } from "../feature.manifest";
|
|
||||||
import type {
|
|
||||||
SignInInput,
|
|
||||||
SignInOutput,
|
|
||||||
} from "../application/use-cases/sign-in.use-case";
|
|
||||||
import { authContainer } from "./container";
|
import { authContainer } from "./container";
|
||||||
import { AUTH_SYMBOLS } from "./symbols";
|
import { AUTH_SYMBOLS } from "./symbols";
|
||||||
import { UsersRepository } from "../infrastructure/repositories/users.repository";
|
import { UsersRepository } from "../infrastructure/repositories/users.repository";
|
||||||
@@ -67,55 +64,40 @@ export function bindProductionAuth(ctx: BindProductionContext): void {
|
|||||||
.bind<IAuthenticationService>(AUTH_SYMBOLS.IAuthenticationService)
|
.bind<IAuthenticationService>(AUTH_SYMBOLS.IAuthenticationService)
|
||||||
.toConstantValue(authService);
|
.toConstantValue(authService);
|
||||||
|
|
||||||
// Use cases — wrapped with span + capture at bind time
|
// Use cases
|
||||||
const wrappedSignIn: ProductionUseCase<
|
const wrappedSignIn = wireUseCase({
|
||||||
SignInInput,
|
container: authContainer,
|
||||||
SignInOutput,
|
symbol: AUTH_SYMBOLS.ISignInUseCase,
|
||||||
AuthManifest["useCases"]["signIn"]
|
factory: signInUseCase,
|
||||||
> = withSpan(
|
deps: [repo, authService],
|
||||||
|
feature: "auth",
|
||||||
|
layer: "use-case",
|
||||||
|
name: "signIn",
|
||||||
tracer,
|
tracer,
|
||||||
{ name: "auth.signIn", op: "use-case" },
|
logger,
|
||||||
withCapture(
|
});
|
||||||
logger,
|
const wrappedSignUp = wireUseCase({
|
||||||
{ feature: "auth", layer: "use-case", name: "auth.signIn" },
|
container: authContainer,
|
||||||
signInUseCase(repo, authService),
|
symbol: AUTH_SYMBOLS.ISignUpUseCase,
|
||||||
),
|
factory: signUpUseCase,
|
||||||
);
|
deps: [repo, authService, bus],
|
||||||
const wrappedSignUp = withSpan(
|
feature: "auth",
|
||||||
|
layer: "use-case",
|
||||||
|
name: "signUp",
|
||||||
tracer,
|
tracer,
|
||||||
{ name: "auth.signUp", op: "use-case" },
|
logger,
|
||||||
withCapture(
|
});
|
||||||
logger,
|
const wrappedSignOut = wireUseCase({
|
||||||
{ feature: "auth", layer: "use-case", name: "auth.signUp" },
|
container: authContainer,
|
||||||
signUpUseCase(repo, authService, bus),
|
symbol: AUTH_SYMBOLS.ISignOutUseCase,
|
||||||
),
|
factory: signOutUseCase,
|
||||||
);
|
deps: [authService],
|
||||||
const wrappedSignOut = withSpan(
|
feature: "auth",
|
||||||
|
layer: "use-case",
|
||||||
|
name: "signOut",
|
||||||
tracer,
|
tracer,
|
||||||
{ name: "auth.signOut", op: "use-case" },
|
logger,
|
||||||
withCapture(
|
});
|
||||||
logger,
|
|
||||||
{ feature: "auth", layer: "use-case", name: "auth.signOut" },
|
|
||||||
signOutUseCase(authService),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
for (const sym of [
|
|
||||||
AUTH_SYMBOLS.ISignInUseCase,
|
|
||||||
AUTH_SYMBOLS.ISignUpUseCase,
|
|
||||||
AUTH_SYMBOLS.ISignOutUseCase,
|
|
||||||
]) {
|
|
||||||
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);
|
|
||||||
|
|
||||||
// Controllers — wrapped with span at bind time
|
// Controllers — wrapped with span at bind time
|
||||||
for (const sym of [
|
for (const sym of [
|
||||||
|
|||||||
Reference in New Issue
Block a user