import type { APIRoute } from 'astro' import { getOAuthClient } from '../../lib/context' import { getSession } from '../../lib/session' export const POST: APIRoute = async (context) => { try { const oauthClient = getOAuthClient(context.cookies) const session = getSession(context.cookies) if (session.did) { try { const oauthSession = await oauthClient.restore(session.did) if (oauthSession) await oauthSession.signOut() } catch (err) { console.warn('Failed to revoke credentials:', err) } } session.destroy() return context.redirect('/') } catch (err) { console.error('Logout failed:', err) return new Response('Logout failed', { status: 500 }) } }