import { c as defineEventHandler, g as getQuery } from '../../_/nitro.mjs';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'node:crypto';
import 'node:url';

const sleep = (ms) => {
  return new Promise((resolve) => {
    setTimeout(resolve, ms);
  });
};

const batchRequest_get = defineEventHandler(async (event) => {
  const addresses = getQuery(event).addresses;
  const addressesArr = Array.isArray(addresses) ? addresses : [addresses];
  const abortController = new AbortController();
  const workingLinks = Object.fromEntries(addressesArr.map((e) => [e, false]));
  for (const link of addressesArr) {
    $fetch(link, {
      signal: abortController.signal
    }).then((data) => {
      workingLinks[link] = Boolean(data != null ? data : false);
    }).catch(() => ({ ok: false }));
  }
  await sleep(500);
  abortController.abort();
  return workingLinks;
});

export { batchRequest_get as default };
//# sourceMappingURL=batch-request.get.mjs.map
