import { json, error } from '@sveltejs/kit'; import type { RequestHandler } from './$types'; /** * GET /api/auth/me * Returns the currently authenticated user from the request's auth cookie. * Returns 401 if not authenticated. */ export const GET: RequestHandler = async ({ locals }) => { if (!locals.user) { error(401, 'Not authenticated'); } return json({ id: locals.user.id, username: locals.user.username, role: locals.user.role }); };