Taylordb client was created

This commit is contained in:
Taylor AI 2025-12-29 13:00:50 +05:00
parent fb7e614dac
commit 0fb69ae14a
3 changed files with 31 additions and 2 deletions

1
.gitignore vendored
View File

@ -27,4 +27,3 @@ dist-ssr
.aider* .aider*
src/lib/taylordb.types.ts src/lib/taylordb.types.ts
src/lib/taylordb.client.ts

View File

@ -0,0 +1,28 @@
import { createQueryBuilder } from "@taylordb/query-builder";
import type { TaylorDatabase } from "./taylordb.types";
let apiKey: string | undefined;
if (typeof window !== "undefined") {
const searchParams = new URLSearchParams(window.location.search);
const apiKeyFromParams = searchParams.get("apiKey");
if (apiKeyFromParams) {
// Store in session storage if found in search params
sessionStorage.setItem("authToken", apiKeyFromParams);
apiKey = apiKeyFromParams;
} else {
// If not in search params, try to get it from session storage
apiKey = sessionStorage.getItem("authToken") ?? undefined;
}
}
if (!apiKey) {
throw new Error("No authentication token found");
}
export const queryBuilder = createQueryBuilder<TaylorDatabase>({
baseUrl: import.meta.env.VITE_TAYLORDB_BASE_URL,
baseId: import.meta.env.VITE_TAYLORDB_BASE_ID,
apiKey,
});

View File

@ -14,6 +14,8 @@ paths:
environment: environment:
envVars: envVars:
NODE_ENV: production NODE_ENV: production
VITE_TAYLORDB_BASE_ID: vars.TAYLORDB_SERVER_ID
VITE_TAYLORDB_BASE_URL: vars.TAYLORDB_BASE_URL
install: install:
commands: commands: