Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoalh committed Jan 12, 2025
1 parent b6ca77d commit 1856c60
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"imports": {
"COLOR": "https://esm.sh/color@4.2.3",
"COLORNAMESPACELISTCOMMUNITY": "https://esm.sh/color-name-list@11.2.0/dist/colornames.esm.js",
"EXFETCH/": "https://raw.githubusercontent.com/hugoalh/exfetch-es/v0.5.1/",
"EXFETCH/": "https://raw.githubusercontent.com/hugoalh/exfetch-es/v0.6.0/",
"FS/": "https://raw.githubusercontent.com/hugoalh/fs-es/v0.3.1/",
"GHACTIONS/": "https://raw.githubusercontent.com/hugoalh/github-actions-core-es/v0.4.3/",
"ISJSON/": "https://raw.githubusercontent.com/hugoalh/is-json-es/v1.0.4/",
Expand Down
27 changes: 21 additions & 6 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
ExFetch,
userAgentDefault
exFetch,
type ExFetchEventRetryPayload
} from "EXFETCH/mod.ts";
import {
addSecretMask,
Expand Down Expand Up @@ -32,11 +32,9 @@ import {
resolveUsername
} from "./_payload.ts";
console.log("Initialize.");
const exfetch: ExFetch = new ExFetch({
userAgent: `${userAgentDefault} SendDiscordWebhook.GitHubAction/7.0.4`
});
const splitterNewLine = /\r?\n/g;
const splitterCommonDelimiter = /,|\r?\n/g;
const userAgent = `SendDiscordWebhook.GitHubAction/7.0.4`;
writeDebug(`Environment Variables:\n\t${Object.entries(Deno.env.toObject()).map(([key, value]: [string, string]): string => {
return `${key} = ${value}`;
}).join("\n\t")}`);
Expand Down Expand Up @@ -161,11 +159,28 @@ try {
return requestPayloadStringify;
})();
console.log(`Post network request to Discord.`);
const response: Response = await exfetch.fetch(`https://discord.com/api/webhooks/${key}${(discordWebhookUrlParameters.size > 0) ? `?${discordWebhookUrlParameters.toString()}` : ""}`, {
const response: Response = await exFetch(`https://discord.com/api/webhooks/${key}${(discordWebhookUrlParameters.size > 0) ? `?${discordWebhookUrlParameters.toString()}` : ""}`, {
body: requestBody,
headers: requestHeaders,
method: "POST",
redirect: "follow"
}, {
retry: {
onRetry({
countCurrent,
countMaximum,
statusCode,
statusText,
timeWait
}: ExFetchEventRetryPayload): void {
console.log(`Last network request failed with status \`${statusCode} ${statusText}. Retry #${countCurrent}/${countMaximum} after ${timeWait / 1000} seconds\`.`);
},
timeWait: {
maximum: 120000,
minimum: 10000
}
},
userAgent
}).catch((reason: Error): never => {
throw new Error(`Unexpected web request issue: ${reason?.message ?? reason}`);
});
Expand Down

0 comments on commit 1856c60

Please sign in to comment.