Added fetch to the generic uploader options

This allows us to have better control over the behavior of a generic uploader.
This commit is contained in:
Kir_Antipov 2024-01-05 15:21:13 +00:00
parent dfd4e9ac5b
commit 1d6cb47d45

View file

@ -6,6 +6,7 @@ import { JavaVersion } from "@/utils/java";
import { Logger, LoggingStopwatch, NULL_LOGGER } from "@/utils/logging";
import { SecureString } from "@/utils/security";
import { VersionType } from "@/utils/versioning";
import { Fetch, fetch } from "@/utils/net";
import { CurseForgeUploaderOptions } from "./curseforge/curseforge-uploader";
import { GitHubUploaderOptions } from "./github/github-uploader";
import { ModrinthUploaderOptions } from "./modrinth/modrinth-uploader";
@ -20,6 +21,11 @@ export interface GenericPlatformUploaderOptions {
* An optional logger that can be used for recording log messages.
*/
logger?: Logger;
/**
* The Fetch implementation used for making HTTP requests.
*/
fetch?: Fetch;
}
/**
@ -123,6 +129,11 @@ export abstract class GenericPlatformUploader<TOptions extends GenericPlatformUp
*/
protected readonly _logger: Logger;
/**
* The Fetch implementation used for making HTTP requests.
*/
protected readonly _fetch: Fetch;
/**
* Constructs a new {@link PlatformUploader} instance.
*
@ -130,6 +141,7 @@ export abstract class GenericPlatformUploader<TOptions extends GenericPlatformUp
*/
protected constructor(options?: TOptions) {
this._logger = options?.logger || NULL_LOGGER;
this._fetch = options?.fetch || fetch;
}
/**