import type { APIRoute } from 'astro'; import { getSessionFromRequest, verifySession } from '../../../utils/auth.js'; export const prerender = false; export const GET: APIRoute = async ({ request }) => { try { const sessionToken = getSessionFromRequest(request); if (!sessionToken) { return new Response(JSON.stringify({ authenticated: false }), { status: 200, headers: { 'Content-Type': 'application/json' } }); } const session = await verifySession(sessionToken); return new Response(JSON.stringify({ authenticated: session !== null, expires: session?.exp ? new Date(session.exp * 1000).toISOString() : null }), { status: 200, headers: { 'Content-Type': 'application/json' } }); } catch (error) { return new Response(JSON.stringify({ authenticated: false, error: 'Session verification failed' }), { status: 200, headers: { 'Content-Type': 'application/json' } }); } };