mirror of
https://github.com/zadam/trilium.git
synced 2026-03-24 04:40:13 +01:00
chore(standalone): get bootstrap to report not initialized state
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BootstrapDefinition } from '@triliumnext/commons';
|
||||
import { entity_changes, getContext, getSharedBootstrapItems, getSql, routes } from '@triliumnext/core';
|
||||
import { entity_changes, getContext, getSharedBootstrapItems, getSql, routes, sql_init } from '@triliumnext/core';
|
||||
|
||||
import packageJson from '../../package.json' with { type: 'json' };
|
||||
import { type BrowserRequest, BrowserRouter } from './browser_router';
|
||||
@@ -220,10 +220,17 @@ export function registerRoutes(router: BrowserRouter): void {
|
||||
apiRoute("get", "/api/system-checks", () => ({ isCpuArchMismatch: false }));
|
||||
}
|
||||
|
||||
function bootstrapRoute() {
|
||||
function bootstrapRoute(): BootstrapDefinition {
|
||||
const assetPath = ".";
|
||||
|
||||
if (!sql_init.isDbInitialized()) {
|
||||
return {
|
||||
dbInitialized: false
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
dbInitialized: true,
|
||||
...getSharedBootstrapItems(assetPath),
|
||||
appPath: assetPath,
|
||||
device: false, // Let the client detect device type.
|
||||
@@ -248,7 +255,7 @@ function bootstrapRoute() {
|
||||
instanceName: null,
|
||||
appCssNoteIds: [],
|
||||
TRILIUM_SAFE_MODE: false
|
||||
} satisfies BootstrapDefinition;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -169,7 +169,12 @@ async function initialize(): Promise<void> {
|
||||
console.log("[Worker] Router configured");
|
||||
|
||||
console.log("[Worker] Initializing becca...");
|
||||
await coreModule.becca_loader.beccaLoaded;
|
||||
if (coreModule.sql_init.isDbInitialized()) {
|
||||
console.log("[Worker] Database already initialized, loading becca...");
|
||||
await coreModule.becca_loader.beccaLoaded;
|
||||
} else {
|
||||
console.log("[Worker] Database not initialized, skipping becca load (will be loaded during DB initialization)");
|
||||
}
|
||||
|
||||
console.log("[Worker] Initialization complete");
|
||||
} catch (error) {
|
||||
|
||||
@@ -312,7 +312,8 @@ export interface DefinitionObject {
|
||||
inverseRelation?: string;
|
||||
}
|
||||
|
||||
export interface BootstrapDefinition {
|
||||
export type BootstrapDefinition = {
|
||||
dbInitialized: true;
|
||||
device: "mobile" | "desktop" | "print" | false;
|
||||
csrfToken: string;
|
||||
themeCssUrl: string | false;
|
||||
@@ -340,6 +341,8 @@ export interface BootstrapDefinition {
|
||||
iconPackCss: string;
|
||||
iconRegistry: IconRegistry;
|
||||
TRILIUM_SAFE_MODE: boolean;
|
||||
} | {
|
||||
dbInitialized: false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user