2023-05-15 09:23:59 +02:00
|
|
|
import { CompatServiceDefinition } from "nice-grpc/lib/service-definitions";
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
SettingsServiceClient,
|
|
|
|
|
SettingsServiceDefinition,
|
|
|
|
|
} from "../../proto/server/zitadel/settings/v2alpha/settings_service";
|
|
|
|
|
|
2023-05-16 17:34:52 +02:00
|
|
|
import { ZitadelServer, createClient, getServers } from "../../server";
|
2023-05-15 09:23:59 +02:00
|
|
|
|
|
|
|
|
export const getSettings = (server?: string | ZitadelServer) => {
|
|
|
|
|
let config;
|
|
|
|
|
if (server && typeof server === "string") {
|
|
|
|
|
const apps = getServers();
|
|
|
|
|
config = apps.find((a) => a.name === server)?.config;
|
|
|
|
|
} else if (server && typeof server === "object") {
|
|
|
|
|
config = server.config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!config) {
|
|
|
|
|
throw Error("No ZITADEL server found");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return createClient<SettingsServiceClient>(
|
|
|
|
|
SettingsServiceDefinition as CompatServiceDefinition,
|
|
|
|
|
config.apiUrl,
|
|
|
|
|
config.token
|
|
|
|
|
);
|
|
|
|
|
};
|