updated the API to support the new calendar service and added a smoke test for the API.

This commit is contained in:
2026-05-20 16:53:26 -07:00
parent 745d0a2909
commit c423f1191d
4 changed files with 92 additions and 23 deletions
+18 -11
View File
@@ -1,7 +1,6 @@
(function () {
const apiBaseUrlStorageKey = "tarot-time-api-base-url";
const apiKeyStorageKey = "tarot-time-api-key";
const defaultApiBaseUrl = "";
function normalizeBaseUrl(value) {
return String(value || "")
@@ -20,22 +19,33 @@
};
}
function stripLegacyCredentialParams() {
try {
const currentUrl = new URL(window.location.href);
const hadApiKeyParam = currentUrl.searchParams.has("apiKey") || currentUrl.searchParams.has("api_key");
if (!hadApiKeyParam) {
return;
}
currentUrl.searchParams.delete("apiKey");
currentUrl.searchParams.delete("api_key");
const nextUrl = `${currentUrl.pathname}${currentUrl.search}${currentUrl.hash}`;
window.history.replaceState(window.history.state, "", nextUrl);
} catch (_error) {
}
}
function persistConnectionSettings(settings) {
let didPersist = true;
try {
const params = new URLSearchParams(window.location.search || "");
const queryValue = String(params.get("apiBaseUrl") || "").trim();
const queryApiKey = String(params.get("apiKey") || params.get("api_key") || "").trim();
if (queryValue) {
window.localStorage.setItem(apiBaseUrlStorageKey, normalizeBaseUrl(queryValue));
}
if (queryApiKey) {
window.localStorage.setItem(apiKeyStorageKey, normalizeApiKey(queryApiKey));
}
if (settings.apiBaseUrl) {
window.localStorage.setItem(apiBaseUrlStorageKey, settings.apiBaseUrl);
} else {
@@ -58,16 +68,11 @@
try {
const params = new URLSearchParams(window.location.search || "");
const queryValue = String(params.get("apiBaseUrl") || "").trim();
const queryApiKey = String(params.get("apiKey") || params.get("api_key") || "").trim();
if (queryValue) {
window.localStorage.setItem(apiBaseUrlStorageKey, normalizeBaseUrl(queryValue));
}
if (queryApiKey) {
window.localStorage.setItem(apiKeyStorageKey, normalizeApiKey(queryApiKey));
}
const storedBaseUrl = String(window.localStorage.getItem(apiBaseUrlStorageKey) || "").trim();
const storedApiKey = String(window.localStorage.getItem(apiKeyStorageKey) || "").trim();
return normalizeConnectionSettings({
@@ -82,6 +87,8 @@
}
}
stripLegacyCredentialParams();
const initialConnectionSettings = readConfiguredConnectionSettings();
window.TarotAppConfig = {