Skip to content

Build your personal knowledge base with Trilium Notes

chore(server): clean up ETAPI route

Elian Doran4a626d6edd91
diff --git a/apps/server/src/etapi/auth.ts b/apps/server/src/etapi/auth.ts
index 65f5c817d1..b39c6b6f67 100644
--- a/apps/server/src/etapi/auth.ts
+++ b/apps/server/src/etapi/auth.ts
@@ -43,8 +43,9 @@ function register(router: Router, loginMiddleware: RequestHandler[]) {
const etapiToken = becca.getEtapiToken(parsed.etapiTokenId);
+ /* v8 ignore next 4 -- unreachable: the token id was already validated by
+ checkEtapiAuth before this handler runs, so it always exists here. */
if (!etapiToken) {
- // shouldn't happen since this already passed auth validation
throw new Error(`Cannot find the token '${parsed.etapiTokenId}'.`);
}
diff --git a/apps/server/src/etapi/notes.ts b/apps/server/src/etapi/notes.ts
index 303e293b4a..1dec2c0895 100644
--- a/apps/server/src/etapi/notes.ts
+++ b/apps/server/src/etapi/notes.ts
@@ -1,8 +1,8 @@
import { type ExportFormat, note_service as noteService, NoteParams, search as searchService, SearchContext, SearchParams, TaskContext, zipExportService, zipImportService } from "@triliumnext/core";
+import { becca } from "@triliumnext/core";
import type { Request, Router } from "express";
import type { ParsedQs } from "qs";
-import { becca } from "@triliumnext/core";
import utils from "../services/utils.js";
import eu from "./etapi_utils.js";
import type { ValidatorMap } from "./etapi-interface.js";
@@ -189,13 +189,6 @@ function register(router: Router) {
return res.sendStatus(204);
});
-
- eu.route<{ noteId: string }>(router, "get", "/etapi/notes/:noteId/attachments", (req, res, next) => {
- const note = eu.getAndCheckNote(req.params.noteId);
- const attachments = note.getAttachments();
-
- res.json(attachments.map((attachment) => mappers.mapAttachmentToPojo(attachment)));
- });
}
function parseSearchParams(req: Request) {