import type { RequestHandler } from '@sveltejs/kit';
import { clearTokens } from '$lib/server/beatleaderAuth';
import { clearSession } from '../../../../lib/server/sessionStore';

export const GET: RequestHandler = async ({ url }) => {
  const redirectTo = url.searchParams.get('redirect_uri') ?? '/';
  return new Response(null, { status: 302, headers: { Location: redirectTo } });
};

export const POST: RequestHandler = async ({ url, cookies }) => {
  clearTokens(cookies);
  clearSession(cookies);
  const redirectTo = url.searchParams.get('redirect_uri') ?? '/';
  return new Response(null, { status: 302, headers: { Location: redirectTo } });
};


