salix/loopback/common/mixins/loggable.js

13 lines
396 B
JavaScript

const LoopBackContext = require('loopback-context');
async function handleObserve(ctx) {
ctx.options.httpCtx = LoopBackContext.getCurrentContext();
}
module.exports = function(Self) {
let Mixin = {
'before save': handleObserve,
'before delete': handleObserve,
};
for (const [listener, handler] of Object.entries(Mixin))
Self.observe(listener, handler);
};