export type GetApiResourceA1Args = {a1: string}; export type GetApiResourceA1Options = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Return the contents of release-note-assets s3 bucket * * GET /resource/{a1} */ export const getApiResourceA1 = async (args: GetApiResourceA1Args, options: GetApiResourceA1Options) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const url = `${baseUrl.replace(/\/+$/, '')}/resource/${encodeURIComponent(String(args.a1))}${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 };