refactor(core): initial multiple servers infra (#8745)

This is the initial refactoring of affine to support multiple servers, but many more changes are needed to make multi-server actually work.
This commit is contained in:
EYHN
2024-11-27 06:44:46 +00:00
parent 3f4cb5be40
commit 6b4a1aa917
80 changed files with 1141 additions and 519 deletions

View File

@@ -998,6 +998,7 @@ query serverConfig {
name
features
type
initialized
credentialsRequirement {
...CredentialsRequirement
}

View File

@@ -8,6 +8,7 @@ query serverConfig {
name
features
type
initialized
credentialsRequirement {
...CredentialsRequirement
}

View File

@@ -2,23 +2,3 @@ export * from './error';
export * from './fetcher';
export * from './graphql';
export * from './schema';
import { setupGlobal } from '@affine/env/global';
import { gqlFetcherFactory } from './fetcher';
setupGlobal();
export function getBaseUrl(): string {
if (BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS || BUILD_CONFIG.isAndroid) {
return BUILD_CONFIG.serverUrlPrefix;
}
if (typeof window === 'undefined') {
// is nodejs
return '';
}
const { protocol, hostname, port } = window.location;
return `${protocol}//${hostname}${port ? `:${port}` : ''}`;
}
export const fetcher = gqlFetcherFactory(getBaseUrl() + '/graphql');

View File

@@ -2175,6 +2175,7 @@ export type ServerConfigQuery = {
name: string;
features: Array<ServerFeature>;
type: ServerDeploymentType;
initialized: boolean;
credentialsRequirement: {
__typename?: 'CredentialsRequirementType';
password: {