export type GetApiApiR2KeyArgs = {key: string}; export type GetApiApiR2KeyOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Read one public immutable metadata or image object * * GET /api/r2/{key} */ export const getApiApiR2Key = async (args: GetApiApiR2KeyArgs, options?: GetApiApiR2KeyOptions) => { const {baseUrl = "https://rugspull.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const url = `${baseUrl.replace(/\/+$/, '')}/api/r2/${encodeURIComponent(String(args.key))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };