Skip to content

Build your personal knowledge base with Trilium Notes

chore(core): port recent changes route

Elian Doran1ed39996399b
diff --git a/apps/server/src/routes/routes.ts b/apps/server/src/routes/routes.ts
index ed180fdc23..889854c4bd 100644
--- a/apps/server/src/routes/routes.ts
+++ b/apps/server/src/routes/routes.ts
@@ -38,7 +38,6 @@ import ollamaRoute from "./api/ollama.js";
import openaiRoute from "./api/openai.js";
import otherRoute from "./api/other.js";
import passwordApiRoute from "./api/password.js";
-import recentChangesApiRoute from "./api/recent_changes.js";
import recoveryCodes from './api/recovery_codes.js';
import scriptRoute from "./api/script.js";
import searchRoute from "./api/search.js";
@@ -261,7 +260,6 @@ function register(app: express.Application) {
route(GET, "/api/fonts", [auth.checkApiAuthOrElectron], fontsRoute.getFontCss);
apiRoute(PST, "/api/other/render-markdown", otherRoute.renderMarkdown);
apiRoute(PST, "/api/other/to-markdown", otherRoute.toMarkdown);
- apiRoute(GET, "/api/recent-changes/:ancestorNoteId", recentChangesApiRoute.getRecentChanges);
apiRoute(PST, "/api/note-map/:noteId/tree", noteMapRoute.getTreeMap);
apiRoute(PST, "/api/note-map/:noteId/link", noteMapRoute.getLinkMap);
diff --git a/apps/server/src/routes/api/recent_changes.ts b/packages/trilium-core/src/routes/api/recent_changes.ts
similarity index 98%
rename from apps/server/src/routes/api/recent_changes.ts
rename to packages/trilium-core/src/routes/api/recent_changes.ts
index 9dd2465888..bb694de9d0 100644
--- a/apps/server/src/routes/api/recent_changes.ts
+++ b/packages/trilium-core/src/routes/api/recent_changes.ts
@@ -1,17 +1,18 @@
"use strict";
-import sql from "../../services/sql.js";
import protectedSessionService from "../../services/protected_session.js";
import noteService from "../../services/notes.js";
import becca from "../../becca/becca.js";
import type { Request } from "express";
import type { RecentChangeRow } from "@triliumnext/commons";
+import { getSql } from "../../services/sql/index.js";
function getRecentChanges(req: Request) {
const { ancestorNoteId } = req.params;
let recentChanges: RecentChangeRow[] = [];
+ const sql = getSql();
const revisionRows = sql.getRows<RecentChangeRow>(`
SELECT
notes.noteId,
diff --git a/packages/trilium-core/src/routes/index.ts b/packages/trilium-core/src/routes/index.ts
index 9be361452a..52fe1383e8 100644
--- a/packages/trilium-core/src/routes/index.ts
+++ b/packages/trilium-core/src/routes/index.ts
@@ -15,6 +15,7 @@ import sqlRoute from "./api/sql";
import attributesRoute from "./api/attributes";
import revisionsApiRoute from "./api/revisions";
import relationMapApiRoute from "./api/relation-map";
+import recentChangesApiRoute from "./api/recent_changes";
// TODO: Deduplicate with routes.ts
const GET = "get",
@@ -111,6 +112,7 @@ export function buildSharedApiRoutes(apiRoute: any) {
apiRoute(GET, "/api/app-info", appInfoRoute.getAppInfo);
apiRoute(GET, "/api/other/icon-usage", otherRoute.getIconUsage);
apiRoute(PST, "/api/relation-map", relationMapApiRoute.getRelationMap);
+ apiRoute(GET, "/api/recent-changes/:ancestorNoteId", recentChangesApiRoute.getRecentChanges);
}
/** Handling common patterns. If entity is not caught, serialization to JSON will fail */