tracks lexicons and how many times they appeared on the jetstream
at migrate 764 B view raw
1import { dev } from "$app/environment"; 2import type { Events, Since } from "./types"; 3import { PUBLIC_API_URL } from "$env/static/public"; 4 5export const fetchEvents = async (): Promise<Events> => { 6 const response = await fetch( 7 `${dev ? "http" : "https"}://${PUBLIC_API_URL}/events`, 8 ); 9 if (!response.ok) { 10 throw new Error(`(${response.status}): ${await response.json()}`); 11 } 12 13 const data = await response.json(); 14 return data; 15}; 16 17export const fetchTrackingSince = async (): Promise<Since> => { 18 const response = await fetch( 19 `${dev ? "http" : "https"}://${PUBLIC_API_URL}/since`, 20 ); 21 if (!response.ok) { 22 throw new Error(`(${response.status}): ${await response.json()}`); 23 } 24 25 const data = await response.json(); 26 return data; 27};