export type GetApiBadgeHealthOwnerRepoSvgArgs = {owner: string, repo: string, variant?: string | undefined, style?: string | undefined}; export type GetApiBadgeHealthOwnerRepoSvgOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Health Badge * * GET /badge/health/{owner}/{repo}.svg */ export const getApiBadgeHealthOwnerRepoSvg = async (args: GetApiBadgeHealthOwnerRepoSvgArgs, options: GetApiBadgeHealthOwnerRepoSvgOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args.variant != null) query.append("variant", String(args.variant)) if (args.style != null) query.append("style", String(args.style)) const url = `${baseUrl.replace(/\/+$/, '')}/badge/health/${encodeURIComponent(String(args.owner))}/${encodeURIComponent(String(args.repo))}.svg${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 res.text() };