import { atom } from "nanostores"; import { checkSession } from "../api/client"; import type { UserProfile } from "../types"; export const $user = atom(null); export const $isLoading = atom(true); export async function initAuth() { $isLoading.set(true); const session = await checkSession(); $user.set(session); $isLoading.set(false); } export function logout() { fetch("/auth/logout", { method: "POST" }).then(() => { window.location.href = "/"; }); }