trilium/src/etapi/spec.js
2022-01-08 19:30:46 +01:00

21 lines
482 B
JavaScript

const fs = require('fs');
const path = require('path');
const specPath = path.join(__dirname, 'etapi.openapi.yaml');
let spec = null;
function register(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);
});
}
module.exports = {
register
};