mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	fix(nx/docker): access to ETAPI
This commit is contained in:
		| @@ -2,13 +2,13 @@ import type { Router } from "express"; | |||||||
|  |  | ||||||
| import fs from "fs"; | import fs from "fs"; | ||||||
| import path from "path"; | import path from "path"; | ||||||
|  | import { RESOURCE_DIR } from "../services/resource_dir"; | ||||||
|  |  | ||||||
| import { fileURLToPath } from "url"; | const specPath = path.join(RESOURCE_DIR, "etapi.openapi.yaml"); | ||||||
| const specPath = path.join(path.dirname(fileURLToPath(import.meta.url)), "etapi.openapi.yaml"); |  | ||||||
| let spec: string | null = null; | let spec: string | null = null; | ||||||
|  |  | ||||||
| function register(router: Router) { | function register(router: Router) { | ||||||
|     router.get("/etapi/etapi.openapi.yaml", (req, res, next) => { |     router.get("/etapi/etapi.openapi.yaml", (_, res) => { | ||||||
|         if (!spec) { |         if (!spec) { | ||||||
|             spec = fs.readFileSync(specPath, "utf8"); |             spec = fs.readFileSync(specPath, "utf8"); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -1,16 +1,14 @@ | |||||||
| import type { Application } from "express"; | import type { Application } from "express"; | ||||||
| import swaggerUi from "swagger-ui-express"; | import swaggerUi from "swagger-ui-express"; | ||||||
| import { fileURLToPath } from "url"; | import { join } from "path"; | ||||||
| import { dirname, join } from "path"; |  | ||||||
| import yaml from "js-yaml"; | import yaml from "js-yaml"; | ||||||
| import type { JsonObject } from "swagger-ui-express"; | import type { JsonObject } from "swagger-ui-express"; | ||||||
| import { readFileSync } from "fs"; | import { readFileSync } from "fs"; | ||||||
|  | import { RESOURCE_DIR } from "../services/resource_dir"; | ||||||
| const __dirname = dirname(fileURLToPath(import.meta.url)); |  | ||||||
|  |  | ||||||
| export default function register(app: Application) { | export default function register(app: Application) { | ||||||
|     const etapiDocument = yaml.load(readFileSync(join(__dirname, "../etapi/etapi.openapi.yaml"), "utf8")) as JsonObject; |     const etapiDocument = yaml.load(readFileSync(join(RESOURCE_DIR, "etapi.openapi.yaml"), "utf8")) as JsonObject; | ||||||
|     const apiDocument = JSON.parse(readFileSync(join(__dirname, "api", "openapi.json"), "utf-8")); |     const apiDocument = JSON.parse(readFileSync(join(RESOURCE_DIR, "openapi.json"), "utf-8")); | ||||||
|  |  | ||||||
|     app.use( |     app.use( | ||||||
|         "/etapi/docs/", |         "/etapi/docs/", | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user