Files
suwayomi-material-you-webui/src/lib/requests/client/BaseClient.ts

28 lines
886 B
TypeScript
Raw Normal View History

2023-08-15 14:39:45 +02:00
/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
2024-10-05 23:22:42 +02:00
import { AppStorage } from '@/lib/storage/AppStorage.ts';
2023-08-15 14:39:45 +02:00
export abstract class BaseClient<Client, ClientConfig, Fetcher> {
protected abstract client: Client;
2023-08-15 14:39:45 +02:00
public abstract readonly fetcher: Fetcher;
public getBaseUrl(): string {
const { hostname, port, protocol } = window.location;
const defaultUrl = import.meta.env.DEV
? import.meta.env.VITE_SERVER_URL_DEFAULT
: `${protocol}//${hostname}:${port}`;
return AppStorage.local.getItemParsed('serverBaseURL', defaultUrl);
2023-08-15 14:39:45 +02:00
}
public abstract updateConfig(config: Partial<ClientConfig>): void;
}