cls-proxify
Version:
Logging on steroids with CLS and Proxy. Integrated with express, koa, fastify.
23 lines (22 loc) • 762 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getClsHookedStorage = exports.setClsHookedStorage = exports.ClsHookedStorage = void 0;
const cls_hooked_1 = require("cls-hooked");
class ClsHookedStorage {
constructor() {
this.namespace = cls_hooked_1.createNamespace('clsProxifyNamespace');
this.key = 'cls-proxify';
}
set(proxy) {
this.namespace.set(this.key, proxy);
}
get() {
return this.namespace.get(this.key);
}
}
exports.ClsHookedStorage = ClsHookedStorage;
let clsHookedStorage = new ClsHookedStorage();
exports.setClsHookedStorage = (newClsHookedStorage) => {
clsHookedStorage = newClsHookedStorage;
};
exports.getClsHookedStorage = () => clsHookedStorage;