your personal website on atproto - mirror blento.app
at bump-text-padding 30 lines 1.0 kB view raw
1import { getDetailedProfile } from '$lib/atproto'; 2import { createCache } from '$lib/cache'; 3import { json } from '@sveltejs/kit'; 4import type { AppBskyActorDefs } from '@atcute/bluesky'; 5 6export async function GET({ platform }) { 7 const cache = createCache(platform); 8 if (!cache) return json('no cache'); 9 10 const existingUsers = await cache.get('meta', 'updatedBlentos'); 11 12 const existingUsersArray: AppBskyActorDefs.ProfileViewDetailed[] = existingUsers 13 ? JSON.parse(existingUsers) 14 : []; 15 16 const existingUsersSet = new Set(existingUsersArray.map((v) => v.did)); 17 18 const newProfilesPromises: Promise<AppBskyActorDefs.ProfileViewDetailed | undefined>[] = []; 19 for (const did of Array.from(existingUsersSet)) { 20 const profile = getDetailedProfile({ did }); 21 newProfilesPromises.push(profile); 22 if (newProfilesPromises.length > 20) break; 23 } 24 25 const newProfiles = await Promise.all(newProfilesPromises); 26 27 await cache.put('meta', 'updatedBlentos', JSON.stringify(newProfiles)); 28 29 return json('ok'); 30}