export type CreateApiCronCheckUpkeepArgs = {'X-CRON-API-KEY': string}; export type CreateApiCronCheckUpkeepOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Check DRE vault upkeep and perform when needed (cron) * * POST /cron/check-upkeep */ export const createApiCronCheckUpkeep = async (args: CreateApiCronCheckUpkeepArgs, options: CreateApiCronCheckUpkeepOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['X-CRON-API-KEY'] != null) headers.set("X-CRON-API-KEY", String(args['X-CRON-API-KEY'])) const url = `${baseUrl.replace(/\/+$/, '')}/cron/check-upkeep${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 };