mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
23 lines
528 B
TypeScript
23 lines
528 B
TypeScript
import { Router } from "express";
|
|
|
|
import fs from "fs";
|
|
import path from "path";
|
|
|
|
const specPath = path.join(__dirname, '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
|
|
};
|