import type { Handle } from '@sveltejs/kit'; import { getSessionAgent } from '$lib/server/auth'; import { startIngester } from '$lib/server/atproto/ingester'; // Start the AT Protocol ingester when the server starts startIngester(); const handleAuth: Handle = async ({ event, resolve }) => { // Get the AT Protocol agent for the current session const agent = await getSessionAgent(event); // Store the agent in locals for use in routes event.locals.agent = agent; event.locals.user = agent ? { did: agent.assertDid } : null; return resolve(event); }; export const handle: Handle = handleAuth;