import { writable } from "svelte/store"; import { checkSession } from "../clients/amplify"; function createAuthStore() { const {set, subscribe} = writable({checked: false, loggedIn: false}) return { subscribe, async check() { try { const loggedIn = await checkSession(); set({checked: true, loggedIn }); } catch(err) { set({checked: true, loggedIn: false }); } } } } const authStore = createAuthStore(); export default authStore;