fix: use svelte store to init bsky client
All checks were successful
create archive with lfs / tag (push) Successful in 9s

This commit is contained in:
dusk 2024-10-30 16:59:38 +03:00
parent 4a4db8e610
commit a2ac850abb
Signed by: dusk
SSH Key Fingerprint: SHA256:Abmvag+juovVufZTxyWY8KcVgrznxvBjQpJesv071Aw
2 changed files with 3 additions and 2 deletions

View File

@ -26,4 +26,4 @@ const loginToBsky = () => {
creds.login({identifier: 'gaze.systems', password: env.BSKY_PASSWORD ?? "" }) creds.login({identifier: 'gaze.systems', password: env.BSKY_PASSWORD ?? "" })
return new Agent(creds) return new Agent(creds)
} }
export const bskyClient = loginToBsky() export const bskyClient = writable(loginToBsky())

View File

@ -2,6 +2,7 @@ import { env } from '$env/dynamic/private';
import { PUBLIC_BASE_URL } from '$env/static/public'; import { PUBLIC_BASE_URL } from '$env/static/public';
import { bskyClient } from '$lib'; import { bskyClient } from '$lib';
import { createNote } from '$lib/notes.js'; import { createNote } from '$lib/notes.js';
import { get } from 'svelte/store';
export const POST = async ({ request }) => { export const POST = async ({ request }) => {
@ -19,7 +20,7 @@ export const POST = async ({ request }) => {
const noteId = createNote({ content: noteData.content, published }) const noteId = createNote({ content: noteData.content, published })
// bridge to bsky if want to bridge // bridge to bsky if want to bridge
if (noteData.bskyPosse ?? null !== null) { if (noteData.bskyPosse ?? null !== null) {
await bskyClient.post({text: `${noteData.content} (${PUBLIC_BASE_URL}/log?id=${noteId})`}) await get(bskyClient).post({text: `${noteData.content} (${PUBLIC_BASE_URL}/log?id=${noteId})`})
} }
// send back created note id // send back created note id
return new Response(JSON.stringify({ noteId }), { return new Response(JSON.stringify({ noteId }), {