your personal website on atproto - mirror blento.app

remove api routes

Florian 573b3c21 99b8faa4

-62
-30
src/routes/api/reloadRecent/+server.ts
··· 1 - import { getDetailedProfile } from '$lib/atproto'; 2 - import { createCache } from '$lib/cache'; 3 - import { json } from '@sveltejs/kit'; 4 - import type { AppBskyActorDefs } from '@atcute/bluesky'; 5 - 6 - export 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 - }
-32
src/routes/api/update/+server.ts
··· 1 - import { createCache } from '$lib/cache'; 2 - import { getCache, loadData } from '$lib/website/load'; 3 - import { env } from '$env/dynamic/private'; 4 - import { json } from '@sveltejs/kit'; 5 - import type { AppBskyActorDefs } from '@atcute/bluesky'; 6 - 7 - export async function GET({ platform }) { 8 - const cache = createCache(platform); 9 - if (!cache) return json('no cache'); 10 - 11 - const existingUsers = await cache.get('meta', 'updatedBlentos'); 12 - 13 - const existingUsersArray: AppBskyActorDefs.ProfileViewDetailed[] = existingUsers 14 - ? JSON.parse(existingUsers) 15 - : []; 16 - 17 - const existingUsersHandle = existingUsersArray.map((v) => v.handle); 18 - 19 - for (const handle of existingUsersHandle) { 20 - if (!handle) continue; 21 - 22 - try { 23 - const cached = await getCache(handle, 'self', cache); 24 - if (!cached) await loadData(handle, cache, true, 'self', env); 25 - } catch (error) { 26 - console.error(error); 27 - return json('error'); 28 - } 29 - } 30 - 31 - return json('ok'); 32 - }