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); };