UNPKG

@aikidosec/firewall

Version:

Zen by Aikido is an embedded Web Application Firewall that autonomously protects Node.js apps against common and critical attacks

23 lines (22 loc) 832 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.wrapRequestHandler = wrapRequestHandler; /* eslint-disable prefer-rest-params */ const Context_1 = require("../../agent/Context"); const contextFromRequest_1 = require("./contextFromRequest"); function wrapRequestHandler(handler) { return function wrapped() { if (arguments.length === 0) { return handler.apply( // @ts-expect-error We don't know the type of this this); } const req = arguments[0]; const context = (0, contextFromRequest_1.contextFromRequest)(req); return (0, Context_1.runWithContext)(context, () => { return handler.apply( // @ts-expect-error We don't know the type of this this, arguments); }); }; }