UNPKG

probot

Version:

A framework for building GitHub Apps to automate and improve your workflow

32 lines (31 loc) • 1.07 kB
import { npxImport } from "npx-import-light"; let SmeeClient; export const createWebhookProxy = async (opts) => { let SmeeClientConstructor; try { const loaded = opts.smeeClient || (opts.loadSmeeClient ? (await opts.loadSmeeClient()).SmeeClient : (SmeeClient ??= (await npxImport("smee-client@5.0.0", { onlyPackageRunner: true, })).SmeeClient)); SmeeClientConstructor = typeof loaded === "function" ? loaded : loaded?.SmeeClient; } catch { opts.logger.warn("Run `npm install --save-dev smee-client` to proxy webhooks to localhost."); return undefined; } if (!SmeeClientConstructor) { throw new Error("SmeeClient is unavailable"); } const smeeClient = new SmeeClientConstructor({ logger: opts.logger, source: opts.url, target: `http://${opts.host}:${opts.port}${opts.path}`, fetch: opts.fetch, }); return await smeeClient.start(); };