import https from "https";
import http from "http";

/**
 * Helper function to do an HTTP request and just await transmission, but not await a response.
 * ref: https://www.sensedeep.com/blog/posts/stories/lambda-fast-http.html
 * @param url - the URL to do HTTP request to
 * @returns promise signalling HTTP request has been transmitted
 */
export async function lambdaFastHttp(url: string): Promise<void> {
  return new Promise((resolve, reject) => {
    let req;

    if (url.startsWith("https://")) {
      req = https.request(url);
    } else {
      req = http.request(url);
    }
    req.end(() => {
      resolve();
    });
  });
}