2018-03-29 11:41:22 +08:00
|
|
|
const clsHooked = require('cls-hooked');
|
|
|
|
const namespace = clsHooked.createNamespace("trilium");
|
|
|
|
|
|
|
|
async function init(callback) {
|
|
|
|
return await namespace.runAndReturn(callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
function wrap(callback) {
|
|
|
|
return async () => await init(callback);
|
|
|
|
}
|
|
|
|
|
2018-03-31 01:20:36 +08:00
|
|
|
function getSourceId() {
|
|
|
|
return namespace.get('sourceId');
|
|
|
|
}
|
|
|
|
|
2018-07-23 01:56:20 +08:00
|
|
|
function reset() {
|
|
|
|
clsHooked.reset();
|
|
|
|
}
|
|
|
|
|
2018-03-29 11:41:22 +08:00
|
|
|
module.exports = {
|
|
|
|
init,
|
|
|
|
wrap,
|
2018-03-31 01:20:36 +08:00
|
|
|
namespace,
|
2018-07-23 01:56:20 +08:00
|
|
|
getSourceId,
|
|
|
|
reset
|
2018-03-29 11:41:22 +08:00
|
|
|
};
|