async function checkForNewPackage()

in functions/GPOPackagesFunction/index.js [142:165]


async function checkForNewPackage(searchDate) {
  console.log(searchDate);
  // the file date has the month name of the end of the quarter so we need to subtract a monthh
  searchDate.setMonth(searchDate.getMonth() - 1);

  // get the string value of the month from the Date object
  const searchMonth = searchDate.toLocaleString("default", { month: "long" });

  // create the file name to look for using the naming convention of the previous packages from DISA
  pkgFileName = `U_STIG_GPO_Package_${searchMonth}_${searchDate.getFullYear()}`;

  // form the options for making a request for the new package
  var options = {
    method: "HEAD",
    hostname: disa.DownloadBaseUrl,
    protocol: "https:",
    port: 443,
    path: `${disa.PackagePath}${pkgFileName}.zip`,
  };

  let res = await makeRequest(options);

  return res.statusCode == "200";
}