+page.ts (1073B)
1 import { _env } from "$lib/utils/_env"; 2 import { error } from "@sveltejs/kit"; 3 import type { PageLoad } from "./$types"; 4 5 const { RADROOTS_MARKET_INDEXES_URL: idx_url } = _env; 6 7 type PageLoadData = { 8 profiles: string[]; 9 countries: string[]; 10 }; 11 12 export const load: PageLoad<PageLoadData> = async ({ fetch, params }) => { 13 if (!idx_url) { 14 return { 15 profiles: [], 16 countries: [], 17 }; 18 } 19 20 const [ 21 res_nip05_indexes, 22 res_country_indexes, 23 ] = await Promise.all([ 24 fetch(`${idx_url}/events/30402/nip05/indexes.json`), 25 fetch(`${idx_url}/events/30402/country/indexes.json`), 26 ]); 27 28 if (!res_nip05_indexes.ok) error(404, { message: `nip05:indexes` }); 29 if (!res_country_indexes.ok) error(404, { message: `country:indexes` }); 30 31 const profiles: string[] = await res_nip05_indexes.json(); 32 const countries: string[] = await res_country_indexes.json(); 33 34 const data: PageLoadData = { 35 profiles, 36 countries, 37 } 38 return data; 39 } 40 41 export const prerender = true;