UNPKG

cls-proxify

Version:

Logging on steroids with CLS and Proxy. Integrated with express, koa, fastify.

14 lines (13 loc) 543 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.clsProxifyExpressMiddleware = void 0; const cls_1 = require("../cls"); exports.clsProxifyExpressMiddleware = (createClsProxy) => (req, res, next) => { cls_1.getClsHookedStorage().namespace.bindEmitter(req); cls_1.getClsHookedStorage().namespace.bindEmitter(res); cls_1.getClsHookedStorage().namespace.run(() => { const proxyValue = createClsProxy(req, res); cls_1.getClsHookedStorage().set(proxyValue); next(); }); };