Skip to content

Commit

Permalink
Fix Fetch with Both HTTP or HTTPS support (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
AleDore authored Jan 3, 2023
1 parent a96e71a commit 6a0fadd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions SendWelcomeMessagesActivity/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { agent } from "@pagopa/ts-commons";
import { getFetch } from "@pagopa/ts-commons/lib/agent";
import {
AbortableFetch,
setFetchTimeout,
Expand All @@ -13,12 +13,12 @@ const DEFAULT_REQUEST_TIMEOUT_MS = 10000;

const config = getConfigOrThrow();

// HTTP-only fetch with optional keepalive agent
// Generic HTTP/HTTPS fetch with optional keepalive agent
// @see https://github.com/pagopa/io-ts-commons/blob/master/src/agent.ts#L10
const httpApiFetch = agent.getHttpFetch(process.env);
const httpOrHttpsApiFetch = getFetch(process.env);

// a fetch that can be aborted and that gets cancelled after fetchTimeoutMs
const abortableFetch = AbortableFetch(httpApiFetch);
const abortableFetch = AbortableFetch(httpOrHttpsApiFetch);
const timeoutFetch = toFetch(
setFetchTimeout(DEFAULT_REQUEST_TIMEOUT_MS as Millisecond, abortableFetch)
);
Expand Down

0 comments on commit 6a0fadd

Please sign in to comment.