From 15e240ac332b38447c3101b430c367cc8af47f69 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 1 Nov 2025 23:37:17 +0200 Subject: [PATCH] refactor(build-docs): remove old Swagger integration --- apps/server/package.json | 2 -- apps/server/src/routes/api_docs.ts | 33 -------------------- apps/server/src/routes/routes.ts | 4 --- packages/share-theme/package.json | 1 - pnpm-lock.yaml | 49 ------------------------------ 5 files changed, 89 deletions(-) delete mode 100644 apps/server/src/routes/api_docs.ts diff --git a/apps/server/package.json b/apps/server/package.json index ed536368d..fa372d70e 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -61,7 +61,6 @@ "@types/serve-static": "2.2.0", "@types/stream-throttle": "0.1.4", "@types/supertest": "6.0.3", - "@types/swagger-ui-express": "4.1.8", "@types/tmp": "0.2.6", "@types/turndown": "5.0.6", "@types/ws": "8.18.1", @@ -123,7 +122,6 @@ "striptags": "3.2.0", "supertest": "7.1.4", "swagger-jsdoc": "6.2.8", - "swagger-ui-express": "5.0.1", "time2fa": "1.4.2", "tmp": "0.2.5", "turndown": "7.2.2", diff --git a/apps/server/src/routes/api_docs.ts b/apps/server/src/routes/api_docs.ts deleted file mode 100644 index df39f3d61..000000000 --- a/apps/server/src/routes/api_docs.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { Application } from "express"; -import swaggerUi from "swagger-ui-express"; -import { join } from "path"; -import yaml from "js-yaml"; -import type { JsonObject } from "swagger-ui-express"; -import { readFileSync } from "fs"; -import { RESOURCE_DIR } from "../services/resource_dir"; - -export default function register(app: Application) { - const etapiDocument = yaml.load(readFileSync(join(RESOURCE_DIR, "etapi.openapi.yaml"), "utf8")) as JsonObject; - - // Load the comprehensive API documentation from YAML - const apiDocument = yaml.load(readFileSync(join(RESOURCE_DIR, "api-openapi.yaml"), "utf8")) as JsonObject; - - app.use( - "/etapi/docs/", - swaggerUi.serveFiles(etapiDocument), - swaggerUi.setup(etapiDocument, { - explorer: true, - customSiteTitle: "TriliumNext ETAPI Documentation" - }) - ); - - app.use( - "/api/docs/", - swaggerUi.serveFiles(apiDocument), - swaggerUi.setup(apiDocument, { - explorer: true, - customSiteTitle: "TriliumNext Internal API Documentation", - customCss: '.swagger-ui .topbar { display: none }' - }) - ); -} diff --git a/apps/server/src/routes/routes.ts b/apps/server/src/routes/routes.ts index 9ba6b686c..9074789f2 100644 --- a/apps/server/src/routes/routes.ts +++ b/apps/server/src/routes/routes.ts @@ -70,7 +70,6 @@ import etapiSpecialNoteRoutes from "../etapi/special_notes.js"; import etapiSpecRoute from "../etapi/spec.js"; import etapiBackupRoute from "../etapi/backup.js"; import etapiMetricsRoute from "../etapi/metrics.js"; -import apiDocsRoute from "./api_docs.js"; import { apiResultHandler, apiRoute, asyncApiRoute, asyncRoute, route, router, uploadMiddlewareWithErrorHandling } from "./route_api.js"; const GET = "get", @@ -383,9 +382,6 @@ function register(app: express.Application) { asyncApiRoute(GET, "/api/llm/providers/openai/models", openaiRoute.listModels); asyncApiRoute(GET, "/api/llm/providers/anthropic/models", anthropicRoute.listModels); - // API Documentation - apiDocsRoute(app); - app.use("", router); } diff --git a/packages/share-theme/package.json b/packages/share-theme/package.json index c03ebc044..ef133f29d 100644 --- a/packages/share-theme/package.json +++ b/packages/share-theme/package.json @@ -32,7 +32,6 @@ "devDependencies": { "@digitak/esrun": "3.2.26", "@triliumnext/ckeditor5": "workspace:*", - "@types/swagger-ui": "5.21.1", "@typescript-eslint/eslint-plugin": "8.46.2", "@typescript-eslint/parser": "8.46.2", "dotenv": "17.2.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a5799c032..f83d8c691 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -582,9 +582,6 @@ importers: '@types/supertest': specifier: 6.0.3 version: 6.0.3 - '@types/swagger-ui-express': - specifier: 4.1.8 - version: 4.1.8 '@types/tmp': specifier: 0.2.6 version: 0.2.6 @@ -768,9 +765,6 @@ importers: swagger-jsdoc: specifier: 6.2.8 version: 6.2.8(openapi-types@12.1.3) - swagger-ui-express: - specifier: 5.0.1 - version: 5.0.1(express@5.1.0) time2fa: specifier: 1.4.2 version: 1.4.2 @@ -1375,9 +1369,6 @@ importers: '@triliumnext/ckeditor5': specifier: workspace:* version: link:../ckeditor5 - '@types/swagger-ui': - specifier: 5.21.1 - version: 5.21.1 '@typescript-eslint/eslint-plugin': specifier: 8.46.2 version: 8.46.2(@typescript-eslint/parser@8.46.2(eslint@9.38.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.38.0(jiti@2.6.1))(typescript@5.9.3) @@ -4505,9 +4496,6 @@ packages: '@rushstack/ts-command-line@5.0.1': resolution: {integrity: sha512-bsbUucn41UXrQK7wgM8CNM/jagBytEyJqXw/umtI8d68vFm1Jwxh1OtLrlW7uGZgjCWiiPH6ooUNa1aVsuVr3Q==} - '@scarf/scarf@1.4.0': - resolution: {integrity: sha512-xxeapPiUXdZAE3che6f3xogoJPeZgig6omHEy1rIY5WVsB3H2BHNnZH+gHG6x91SCWyQCzWGsuL2Hh3ClO5/qQ==} - '@selderee/plugin-htmlparser2@0.11.0': resolution: {integrity: sha512-P33hHGdldxGabLFjPPpaTxVolMrzrcegejx+0GxjrIb9Zv48D8yAIA/QTDR2dFl7Uz7urX8aX6+5bCZslr+gWQ==} @@ -5361,12 +5349,6 @@ packages: '@types/supertest@6.0.3': resolution: {integrity: sha512-8WzXq62EXFhJ7QsH3Ocb/iKQ/Ty9ZVWnVzoTKc9tyyFRRF3a74Tk2+TLFgaFFw364Ere+npzHKEJ6ga2LzIL7w==} - '@types/swagger-ui-express@4.1.8': - resolution: {integrity: sha512-AhZV8/EIreHFmBV5wAs0gzJUNq9JbbSXgJLQubCC0jtIo6prnI9MIRRxnU4MZX9RB9yXxF1V4R7jtLl/Wcj31g==} - - '@types/swagger-ui@5.21.1': - resolution: {integrity: sha512-DUmUH59eeOtvAqcWwBduH2ws0cc5i95KHsXCS4FsOfbUq/clW8TN+HqRBj7q5p9MSsSNK43RziIGItNbrAGLxg==} - '@types/tabulator-tables@6.3.0': resolution: {integrity: sha512-/mQzrThCdSQXc2lz2SUZglIG+vWQ1sb1CEiVxw9SFGKPulaj1543zrL2qABeJIKjKPxcSgmWUyDA9e8CMaI2cQ==} @@ -13423,15 +13405,6 @@ packages: resolution: {integrity: sha512-nF7oMeL4KypldrQhac8RyHerJeGPD1p2xDh900GPvc+Nk7nWP6jX2FcC7WmkinMoAmoO774+AFXcWsW8gMWEIg==} engines: {node: '>=10'} - swagger-ui-dist@5.21.0: - resolution: {integrity: sha512-E0K3AB6HvQd8yQNSMR7eE5bk+323AUxjtCz/4ZNKiahOlPhPJxqn3UPIGs00cyY/dhrTDJ61L7C/a8u6zhGrZg==} - - swagger-ui-express@5.0.1: - resolution: {integrity: sha512-SrNU3RiBGTLLmFU8GIJdOdanJTl4TOmT27tt3bWWHppqYmAZ6IDuEuBvMU6nZq0zLEe6b/1rACXCgLZqO6ZfrA==} - engines: {node: '>= v0.10.32'} - peerDependencies: - express: '>=4.0.0 || >=5.0.0-beta' - swagger2openapi@7.0.8: resolution: {integrity: sha512-upi/0ZGkYgEcLeGieoz8gT74oWHA0E7JivX7aN9mAf+Tc7BQoRBvnIGHoPDw+f9TXTW4s6kGYCZJtauP6OYp7g==} hasBin: true @@ -15554,8 +15527,6 @@ snapshots: '@ckeditor/ckeditor5-utils': 47.1.0 '@ckeditor/ckeditor5-watchdog': 47.1.0 es-toolkit: 1.39.5 - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-dev-build-tools@43.1.0(@swc/helpers@0.5.17)(tslib@2.8.1)(typescript@5.9.3)': dependencies: @@ -15720,8 +15691,6 @@ snapshots: '@ckeditor/ckeditor5-utils': 47.1.0 ckeditor5: 47.1.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) es-toolkit: 1.39.5 - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-editor-classic@47.1.0': dependencies: @@ -19379,8 +19348,6 @@ snapshots: transitivePeerDependencies: - '@types/node' - '@scarf/scarf@1.4.0': {} - '@selderee/plugin-htmlparser2@0.11.0': dependencies: domhandler: 5.0.3 @@ -20465,13 +20432,6 @@ snapshots: '@types/methods': 1.1.4 '@types/superagent': 8.1.9 - '@types/swagger-ui-express@4.1.8': - dependencies: - '@types/express': 5.0.3 - '@types/serve-static': 2.2.0 - - '@types/swagger-ui@5.21.1': {} - '@types/tabulator-tables@6.3.0': {} '@types/through2@2.0.41': @@ -30455,15 +30415,6 @@ snapshots: transitivePeerDependencies: - openapi-types - swagger-ui-dist@5.21.0: - dependencies: - '@scarf/scarf': 1.4.0 - - swagger-ui-express@5.0.1(express@5.1.0): - dependencies: - express: 5.1.0 - swagger-ui-dist: 5.21.0 - swagger2openapi@7.0.8(encoding@0.1.13): dependencies: call-me-maybe: 1.0.2