import { api } from './api'; import type { Me } from './types'; class Session { me = $state(null); ready = $state(false); g1 = $state(false); dev = $state(false); async load() { const [me, cfg] = await Promise.all([ api.get<{ me: Me | null }>('/me').catch(() => ({ me: null })), api.get<{ g1: boolean; dev: boolean }>('/auth/config').catch(() => ({ g1: false, dev: false })), ]); this.me = me.me; this.g1 = cfg.g1; this.dev = cfg.dev; this.ready = true; } async logout() { await api.post('/auth/logout'); this.me = null; } } export const session = new Session();