website refactor
This commit is contained in:
26
apps/website/lib/mutations/auth/LoginMutation.ts
Normal file
26
apps/website/lib/mutations/auth/LoginMutation.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Login Mutation
|
||||
*
|
||||
* Framework-agnostic mutation for login operations.
|
||||
* Called from Server Actions.
|
||||
*
|
||||
* Pattern: Server Action → Mutation → Service → API Client
|
||||
*/
|
||||
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { AuthService } from '@/lib/services/auth/AuthService';
|
||||
import { SessionViewModel } from '@/lib/view-models/SessionViewModel';
|
||||
import { LoginParamsDTO } from '@/lib/types/generated/LoginParamsDTO';
|
||||
|
||||
export class LoginMutation {
|
||||
async execute(params: LoginParamsDTO): Promise<Result<SessionViewModel, string>> {
|
||||
try {
|
||||
const authService = new AuthService();
|
||||
const session = await authService.login(params);
|
||||
return Result.ok(session);
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : 'Login failed';
|
||||
return Result.err(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user