File size: 767 Bytes
097eaf0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Logger } from "winston";

import { robustFetch } from "../../lib/fetch";
import { MockState } from "../../lib/mock";
import { fireEngineURL } from "./scrape";

export async function fireEngineDelete(
  logger: Logger,
  jobId: string | undefined,
  mock: MockState | null,
  abort?: AbortSignal,
  baseUrl: string = fireEngineURL,
) {
  // jobId only supplied if we need to defer deletion
  if (!jobId) {
    logger.debug("Fire Engine job id not supplied, skipping delete");
    return;
  }

  await robustFetch({
    url: `${baseUrl}/scrape/${jobId}`,
    method: "DELETE",
    headers: {},
    logger: logger.child({ method: "fireEngineDelete/robustFetch", jobId }),
    mock,
    abort,
  });

  logger.debug("Deleted job from Fire Engine", { jobId });
}