Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 57 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@
"@mermaid-js/layout-elk": "0.1.7",
"@mind-elixir/node-menu": "1.0.4",
"@triliumnext/express-partial-content": "1.0.1",
"@types/js-yaml": "4.0.9",
"@types/leaflet": "1.9.16",
"@types/react-dom": "18.3.5",
"@types/swagger-ui-express": "4.1.7",
"archiver": "7.0.1",
"async-mutex": "0.5.0",
"autocomplete.js": "0.38.1",
Expand Down Expand Up @@ -113,6 +115,7 @@
"jquery": "3.7.1",
"jquery-hotkeys": "0.2.2",
"jquery.fancytree": "2.38.4",
"js-yaml": "4.1.0",
"jsdom": "26.0.0",
"jsplumb": "2.15.6",
"katex": "0.16.21",
Expand Down Expand Up @@ -141,6 +144,7 @@
"split.js": "1.6.5",
"stream-throttle": "0.1.3",
"striptags": "3.2.0",
"swagger-ui-express": "5.0.1",
"tmp": "0.2.3",
"ts-loader": "9.5.2",
"turndown": "7.2.0",
Expand Down
27 changes: 27 additions & 0 deletions src/routes/api_docs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Router } from "express";
import swaggerUi from "swagger-ui-express";
import { readFile } from "fs/promises";
import { fileURLToPath } from "url";
import { dirname, join } from "path";
import yaml from "js-yaml";
import type { JsonObject } from "swagger-ui-express";

const __dirname = dirname(fileURLToPath(import.meta.url));
const swaggerDocument = yaml.load(
await readFile(join(__dirname, "../etapi/etapi.openapi.yaml"), "utf8")
) as JsonObject;

function register(router: Router) {
router.use(
"/etapi",
swaggerUi.serve,
swaggerUi.setup(swaggerDocument, {
explorer: true,
customSiteTitle: "TriliumNext ETAPI Documentation"
})
);
}

export default {
register
};
5 changes: 4 additions & 1 deletion src/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import etapiSpecialNoteRoutes from "../etapi/special_notes.js";
import etapiSpecRoute from "../etapi/spec.js";
import etapiBackupRoute from "../etapi/backup.js";


import apiDocsRoute from "./api_docs.js";

const MAX_ALLOWED_FILE_SIZE_MB = 250;
const GET = "get",
Expand Down Expand Up @@ -369,6 +369,9 @@ function register(app: express.Application) {
etapiSpecRoute.register(router);
etapiBackupRoute.register(router);

// API Documentation
apiDocsRoute.register(app);

app.use("", router);
}

Expand Down