Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client/lightweight): bootstrap route as part of the new router

Elian Doranc6d1457ad7fd
diff --git a/apps/client/src/lightweight/browser_routes.ts b/apps/client/src/lightweight/browser_routes.ts
index cda9633c5e..18a9da295b 100644
--- a/apps/client/src/lightweight/browser_routes.ts
+++ b/apps/client/src/lightweight/browser_routes.ts
@@ -42,6 +42,25 @@ function createApiRoute(router: BrowserRouter) {
export function registerRoutes(router: BrowserRouter): void {
const apiRoute = createApiRoute(router);
routes.buildSharedApiRoutes(apiRoute);
+ apiRoute('get', '/bootstrap', bootstrapRoute);
+}
+
+function bootstrapRoute() {
+ return {
+ assetPath: "./",
+ baseApiUrl: "../api/",
+ themeCssUrl: null,
+ themeUseNextAsBase: "next",
+ iconPackCss: "",
+ device: "desktop",
+ headingStyle: "default",
+ layoutOrientation: "vertical",
+ platform: "web",
+ isElectron: false,
+ hasNativeTitleBar: false,
+ hasBackgroundEffects: true,
+ currentLocale: { id: "en", rtl: false }
+ };
}
/**
diff --git a/apps/client/src/local-server-worker.ts b/apps/client/src/local-server-worker.ts
index fb55ecde24..b12ab230fe 100644
--- a/apps/client/src/local-server-worker.ts
+++ b/apps/client/src/local-server-worker.ts
@@ -135,60 +135,6 @@ function jsonResponse(obj: unknown, status = 200, extraHeaders = {}) {
};
}
-// Example: your /bootstrap handler placeholder
-async function handleBootstrap() {
- console.log("[Worker] Bootstrap request received");
-
- // Try to initialize with timeout
- let dbInfo: Record<string, unknown> = { dbStatus: 'not initialized' };
-
- try {
- // Wait for initialization (with timeout)
- await Promise.race([
- ensureInitialized(),
- new Promise((_, reject) => setTimeout(() => reject(new Error("Initialization timeout")), 10000))
- ]);
-
- // Query the database
- const stmt = sqlProvider.prepare('SELECT * FROM options');
- const rows = stmt.all() as Array<{ name: string; value: string }>;
- const options: Record<string, string> = {};
- for (const row of rows) {
- options[row.name] = row.value;
- }
-
- dbInfo = {
- sqliteVersion: sqlProvider.version?.libVersion,
- optionsFromDB: options,
- dbStatus: 'connected'
- };
- } catch (e) {
- console.error("[Worker] Error during bootstrap:", e);
- dbInfo = { dbStatus: 'error', error: String(e) };
- }
-
- console.log("[Worker] Sending bootstrap response");
-
- // Later: return real globals from your core state/config.
- return jsonResponse({
- assetPath: "./",
- baseApiUrl: "../api/",
- themeCssUrl: null,
- themeUseNextAsBase: "next",
- iconPackCss: "",
- device: "desktop",
- headingStyle: "default",
- layoutOrientation: "vertical",
- platform: "web",
- isElectron: false,
- hasNativeTitleBar: false,
- hasBackgroundEffects: true,
- currentLocale: { id: "en", rtl: false },
- // Add SQLite info for testing
- sqlite: dbInfo
- });
-}
-
interface LocalRequest {
method: string;
url: string;
@@ -201,11 +147,6 @@ async function dispatch(request: LocalRequest) {
console.log("[Worker] Dispatch:", url.pathname);
- // Bootstrap is handled specially before the router is ready
- if (request.method === "GET" && url.pathname === "/bootstrap") {
- return handleBootstrap();
- }
-
// Ensure initialization is complete and get the router
const appRouter = await ensureInitialized();