mirror of
https://github.com/zadam/trilium.git
synced 2025-12-23 16:49:58 +01:00
chore(monorepo/server): move server-side source code
This commit is contained in:
23
apps/server/src/etapi/spec.ts
Normal file
23
apps/server/src/etapi/spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { Router } from "express";
|
||||
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
import { fileURLToPath } from "url";
|
||||
const specPath = path.join(path.dirname(fileURLToPath(import.meta.url)), "etapi.openapi.yaml");
|
||||
let spec: string | null = null;
|
||||
|
||||
function register(router: Router) {
|
||||
router.get("/etapi/etapi.openapi.yaml", (req, res, next) => {
|
||||
if (!spec) {
|
||||
spec = fs.readFileSync(specPath, "utf8");
|
||||
}
|
||||
|
||||
res.header("Content-Type", "text/plain"); // so that it displays in browser
|
||||
res.status(200).send(spec);
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
register
|
||||
};
|
||||
Reference in New Issue
Block a user