Resolves https://github.com/webrecorder/browsertrix/issues/2048 --------- Co-authored-by: Ilya Kreymer <ikreymer@gmail.com> Co-authored-by: Henry Wilkinson <henry@wilkinson.graphics>
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import appState from "./state";
|
|
|
|
export type AppSettings = {
|
|
registrationEnabled: boolean;
|
|
jwtTokenLifetime: number;
|
|
defaultBehaviorTimeSeconds: number;
|
|
defaultPageLoadTimeSeconds: number;
|
|
maxPagesPerCrawl: number;
|
|
numBrowsers: number;
|
|
maxScale: number;
|
|
billingEnabled: boolean;
|
|
signUpUrl: string;
|
|
salesEmail: string;
|
|
supportEmail: string;
|
|
};
|
|
|
|
export async function getAppSettings(): Promise<AppSettings> {
|
|
if (appState.settings) {
|
|
return appState.settings;
|
|
}
|
|
|
|
const resp = await fetch("/api/settings", {
|
|
headers: { "Content-Type": "application/json" },
|
|
});
|
|
|
|
if (resp.status === 200) {
|
|
return (await resp.json()) as AppSettings;
|
|
} else {
|
|
console.debug(resp);
|
|
|
|
return {
|
|
registrationEnabled: false,
|
|
jwtTokenLifetime: 0,
|
|
defaultBehaviorTimeSeconds: 0,
|
|
defaultPageLoadTimeSeconds: 0,
|
|
maxPagesPerCrawl: 0,
|
|
numBrowsers: 1,
|
|
maxScale: 0,
|
|
billingEnabled: false,
|
|
signUpUrl: "",
|
|
salesEmail: "",
|
|
supportEmail: "",
|
|
};
|
|
}
|
|
}
|