mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix custom resource handler, closes #1125
This commit is contained in:
parent
a89b6711d1
commit
74a7802088
@ -2,12 +2,11 @@ const repository = require('../services/repository');
|
|||||||
const log = require('../services/log');
|
const log = require('../services/log');
|
||||||
const fileUploadService = require('./api/files.js');
|
const fileUploadService = require('./api/files.js');
|
||||||
const scriptService = require('../services/script');
|
const scriptService = require('../services/script');
|
||||||
|
const cls = require('../services/cls');
|
||||||
|
|
||||||
function register(router) {
|
async function handleRequest(req, res) {
|
||||||
// explicitly no CSRF middleware since it's meant to allow integration from external services
|
|
||||||
|
|
||||||
router.all('/custom/:path*', async (req, res, next) => {
|
|
||||||
// express puts content after first slash into 0 index element
|
// express puts content after first slash into 0 index element
|
||||||
|
|
||||||
const path = req.params.path + req.params[0];
|
const path = req.params.path + req.params[0];
|
||||||
|
|
||||||
const attrs = await repository.getEntities("SELECT * FROM attributes WHERE isDeleted = 0 AND type = 'label' AND name IN ('customRequestHandler', 'customResourceProvider')");
|
const attrs = await repository.getEntities("SELECT * FROM attributes WHERE isDeleted = 0 AND type = 'label' AND name IN ('customRequestHandler', 'customResourceProvider')");
|
||||||
@ -60,6 +59,16 @@ function register(router) {
|
|||||||
|
|
||||||
log.info(message);
|
log.info(message);
|
||||||
res.status(404).send(message);
|
res.status(404).send(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
function register(router) {
|
||||||
|
// explicitly no CSRF middleware since it's meant to allow integration from external services
|
||||||
|
|
||||||
|
router.all('/custom/:path*', async (req, res, next) => {
|
||||||
|
cls.namespace.bindEmitter(req);
|
||||||
|
cls.namespace.bindEmitter(res);
|
||||||
|
|
||||||
|
cls.init(() => handleRequest(req, res));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user