import { error, json } from '@sveltejs/kit'; import { filterSession, type Session } from '../../../../hooks.server.js'; export const GET = async ({ locals }) => { const data = (await locals.auth()) as Session; // note: these return types are JUST for this endpoint - rely on status code exclusively for the actual meaning. const headers = { 'Access-Control-Allow-Origin': '*', }; if (data === undefined) return json( { '': '', kind: 'NOT_AUTHENTICATED' as const, message: 'Unauthenticated', }, { status: 403, statusText: 'Forbidden', headers, } ); if (data === null) return json( { '': '', kind: 'EXPIRED' as const, message: 'Session Expired', }, { status: 401, statusText: 'Unauthorized', headers, } ); return json(filterSession(data), { headers, status: 200, statusText: 'OK :3', }); };