export type GetApiApiV1GithubUserAuthorizeArgs = {redirect?: string | undefined}; export type GetApiApiV1GithubUserAuthorizeOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Link GitHub account * * GET /api/v1/github/user/authorize */ export const getApiApiV1GithubUserAuthorize = async (args: GetApiApiV1GithubUserAuthorizeArgs, options: GetApiApiV1GithubUserAuthorizeOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.redirect != null) query.append("redirect", String(args.redirect)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/github/user/authorize${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 };