export type CreateApiApiWebhooksGithubArgs = {'x-github-delivery': string, 'x-github-event': string, 'x-hub-signature-256': string}; export type CreateApiApiWebhooksGithubOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Github Webhook * * POST /api/webhooks/github */ export const createApiApiWebhooksGithub = async (args: CreateApiApiWebhooksGithubArgs, options: CreateApiApiWebhooksGithubOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['x-github-delivery'] != null) headers.set("x-github-delivery", String(args['x-github-delivery'])) if (args['x-github-event'] != null) headers.set("x-github-event", String(args['x-github-event'])) if (args['x-hub-signature-256'] != null) headers.set("x-hub-signature-256", String(args['x-hub-signature-256'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/webhooks/github${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };