website refactor
This commit is contained in:
24
apps/website/lib/mutations/auth/LogoutMutation.ts
Normal file
24
apps/website/lib/mutations/auth/LogoutMutation.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user