Skip to content

Build your personal knowledge base with Trilium Notes

chore(client/lightweight): port tree integration

Elian Dorana2d873d16f88
diff --git a/apps/server/src/routes/routes.ts b/apps/server/src/routes/routes.ts
index b91a099909..97fee7666e 100644
--- a/apps/server/src/routes/routes.ts
+++ b/apps/server/src/routes/routes.ts
@@ -61,7 +61,6 @@ import syncApiRoute from "./api/sync.js";
import systemInfoRoute from "./api/system_info.js";
import totp from './api/totp.js';
// API routes
-import treeApiRoute from "./api/tree.js";
import { doubleCsrfProtection as csrfMiddleware } from "./csrf_protection.js";
import * as indexRoute from "./index.js";
import loginRoute from "./login.js";
@@ -105,6 +104,7 @@ function register(app: express.Application) {
apiRoute(GET, '/api/totp_recovery/enabled', recoveryCodes.checkForRecoveryKeys);
apiRoute(GET, '/api/totp_recovery/used', recoveryCodes.getUsedRecoveryCodes);
+ const { treeApiRoute } = routes;
apiRoute(GET, '/api/tree', treeApiRoute.getTree);
apiRoute(PST, '/api/tree/load', treeApiRoute.load);
diff --git a/apps/server/src/routes/api/tree.ts b/packages/trilium-core/src/routes/api/tree.ts
similarity index 94%
rename from apps/server/src/routes/api/tree.ts
rename to packages/trilium-core/src/routes/api/tree.ts
index 6c1c3c6844..7a7fe8f98d 100644
--- a/apps/server/src/routes/api/tree.ts
+++ b/packages/trilium-core/src/routes/api/tree.ts
@@ -1,10 +1,10 @@
import type { AttributeRow, BranchRow, NoteRow } from "@triliumnext/commons";
-import { NotFoundError } from "@triliumnext/core";
import type { Request } from "express";
import becca from "../../becca/becca.js";
-import type BNote from "../../becca/entities/bnote.js";
-import log from "../../services/log.js";
+import { NotFoundError } from "src/errors.js";
+import { getLog } from "src/services/log.js";
+import type BNote from "src/becca/entities/bnote.js";
function getNotesAndBranchesAndAttributes(_noteIds: string[] | Set<string>) {
const noteIds = new Set(_noteIds);
@@ -85,7 +85,7 @@ function getNotesAndBranchesAndAttributes(_noteIds: string[] | Set<string>) {
const branch = becca.branches[branchId];
if (!branch) {
- log.error(`Could not find branch for branchId=${branchId}`);
+ getLog().error(`Could not find branch for branchId=${branchId}`);
continue;
}
@@ -105,7 +105,7 @@ function getNotesAndBranchesAndAttributes(_noteIds: string[] | Set<string>) {
const attribute = becca.attributes[attributeId];
if (!attribute) {
- log.error(`Could not find attribute for attributeId=${attributeId}`);
+ getLog().error(`Could not find attribute for attributeId=${attributeId}`);
continue;
}
diff --git a/packages/trilium-core/src/routes/index.ts b/packages/trilium-core/src/routes/index.ts
index 36ed23de80..67799a2c0b 100644
--- a/packages/trilium-core/src/routes/index.ts
+++ b/packages/trilium-core/src/routes/index.ts
@@ -1 +1,2 @@
export { default as optionsApiRoute } from "./api/options";
+export { default as treeApiRoute } from "./api/tree";