Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

1.6 KB
Raw Blame
// Must be first - initializes global compatibility shims
import "./init";
import "regenerator-runtime/runtime";
import "./assets/css/github-markdown-style.css";
import "./assets/css/tailwind.css";
import "./stylex-dev-css";
// Side-effect: configures the shared dayjs singleton (localizedFormat) and
// registers the SQL highlight.js language + theme used across the app.
import "./lib/dayjs";
import "./lib/highlight";
import { initializeGA4 } from "./lib/ga4";
import { useAppStore } from "./stores/app";
import {
  isDev,
  isRelease,
  migrateStorageKeys,
  rewriteLegacyPath,
} from "./utils";

console.debug("dev:", isDev());
console.debug("release:", isRelease());

// Migrate renamed localStorage keys before any store reads from storage,
// and renamed URLs before the router mounts.
migrateStorageKeys();
rewriteLegacyPath();

(async () => {
  const store = useAppStore.getState();

  // Load the authenticated session BEFORE mounting so the route guard sees the
  // correct auth state on the very first navigation. Authentication info is
  // independent from the authenticated actuator response and is always loaded.
  const currentUser = await store.loadCurrentUser();
  const initPromises: Promise<unknown>[] = [store.loadAuthenticationInfo()];
  if (currentUser) {
    initPromises.push(store.loadServerInfo());
    initPromises.push(store.loadSubscription());
    initPromises.push(store.loadWorkspaceList());
    initPromises.push(store.loadWorkspaceProfile());
  }
  await Promise.all(initPromises);
  initializeGA4();

  const { mountReactRouterApp } = await import("./app/mountApp");
  await mountReactRouterApp("#app");
})();