Skip to content

Build your personal knowledge base with Trilium Notes

fix(nx/docker): access to ETAPI

Elian Doran73bfff34dbd6
diff --git a/apps/server/src/etapi/etapi.openapi.yaml b/apps/server/src/assets/etapi.openapi.yaml
similarity index 100%
rename from apps/server/src/etapi/etapi.openapi.yaml
rename to apps/server/src/assets/etapi.openapi.yaml
diff --git a/apps/server/src/routes/api/openapi.json b/apps/server/src/assets/openapi.json
similarity index 100%
rename from apps/server/src/routes/api/openapi.json
rename to apps/server/src/assets/openapi.json
diff --git a/apps/server/src/etapi/spec.ts b/apps/server/src/etapi/spec.ts
index 925ff51a65..7ef963f8f9 100644
--- a/apps/server/src/etapi/spec.ts
+++ b/apps/server/src/etapi/spec.ts
@@ -2,13 +2,13 @@ import type { Router } from "express";
import fs from "fs";
import path from "path";
+import { RESOURCE_DIR } from "../services/resource_dir";
-import { fileURLToPath } from "url";
-const specPath = path.join(path.dirname(fileURLToPath(import.meta.url)), "etapi.openapi.yaml");
+const specPath = path.join(RESOURCE_DIR, "etapi.openapi.yaml");
let spec: string | null = null;
function register(router: Router) {
- router.get("/etapi/etapi.openapi.yaml", (req, res, next) => {
+ router.get("/etapi/etapi.openapi.yaml", (_, res) => {
if (!spec) {
spec = fs.readFileSync(specPath, "utf8");
}
diff --git a/apps/server/src/routes/api_docs.ts b/apps/server/src/routes/api_docs.ts
index 78d790bb5c..122ae44b01 100644
--- a/apps/server/src/routes/api_docs.ts
+++ b/apps/server/src/routes/api_docs.ts
@@ -1,16 +1,14 @@
import type { Application } from "express";
import swaggerUi from "swagger-ui-express";
-import { fileURLToPath } from "url";
-import { dirname, join } from "path";
+import { join } from "path";
import yaml from "js-yaml";
import type { JsonObject } from "swagger-ui-express";
import { readFileSync } from "fs";
-
-const __dirname = dirname(fileURLToPath(import.meta.url));
+import { RESOURCE_DIR } from "../services/resource_dir";
export default function register(app: Application) {
- const etapiDocument = yaml.load(readFileSync(join(__dirname, "../etapi/etapi.openapi.yaml"), "utf8")) as JsonObject;
- const apiDocument = JSON.parse(readFileSync(join(__dirname, "api", "openapi.json"), "utf-8"));
+ const etapiDocument = yaml.load(readFileSync(join(RESOURCE_DIR, "etapi.openapi.yaml"), "utf8")) as JsonObject;
+ const apiDocument = JSON.parse(readFileSync(join(RESOURCE_DIR, "openapi.json"), "utf-8"));
app.use(
"/etapi/docs/",