24 lines
660 B
TypeScript
24 lines
660 B
TypeScript
/**
|
|
* Logout Mutation
|
|
*
|
|
* Framework-agnostic mutation for logout 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';
|
|
|
|
export class LogoutMutation {
|
|
async execute(): Promise<Result<void, string>> {
|
|
try {
|
|
const authService = new AuthService();
|
|
await authService.logout();
|
|
return Result.ok(undefined);
|
|
} catch (error) {
|
|
const errorMessage = error instanceof Error ? error.message : 'Logout failed';
|
|
return Result.err(errorMessage);
|
|
}
|
|
}
|
|
} |