mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-08 20:32:46 +08:00
feat: add webdav support
This commit is contained in:
33
app/utils/cloud/index.ts
Normal file
33
app/utils/cloud/index.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { createWebDavClient } from "./webdav";
|
||||
import { createUpstashClient } from "./upstash";
|
||||
|
||||
export enum ProviderType {
|
||||
WebDAV = "webdav",
|
||||
UpStash = "upstash",
|
||||
}
|
||||
|
||||
export const SyncClients = {
|
||||
[ProviderType.UpStash]: createUpstashClient,
|
||||
[ProviderType.WebDAV]: createWebDavClient,
|
||||
} as const;
|
||||
|
||||
type SyncClientConfig = {
|
||||
[K in keyof typeof SyncClients]: (typeof SyncClients)[K] extends (
|
||||
_: infer C,
|
||||
) => any
|
||||
? C
|
||||
: never;
|
||||
};
|
||||
|
||||
export type SyncClient = {
|
||||
get: (key: string) => Promise<string>;
|
||||
set: (key: string, value: string) => Promise<void>;
|
||||
check: () => Promise<boolean>;
|
||||
};
|
||||
|
||||
export function createSyncClient<T extends ProviderType>(
|
||||
provider: T,
|
||||
config: SyncClientConfig[T],
|
||||
): SyncClient {
|
||||
return SyncClients[provider](config as any) as any;
|
||||
}
|
Reference in New Issue
Block a user