async function areRegionsValid()

in source/services/helper/index.ts [420:442]


async function areRegionsValid(regions: string[], awsRegions: string[]) {
  logger.debug({
    label: "helper/areRegionsValid",
    message: `checking if region parameter is valid`,
  });

  if (!(awsRegions instanceof Array)) throw new Error("no regions found");
  try {
    await Promise.all(
      regions.map((region) => {
        if (!awsRegions.includes(region))
          throw new Error("invalid region provided");
      })
    );
    return true;
  } catch (e) {
    logger.error({
      label: "helper/areRegionsValid",
      message: `${(e as Error).message}`,
    });
    return false;
  }
}