UNPKG

@aikidosec/firewall

Version:

Zen by Aikido is an embedded Application Firewall that autonomously protects Node.js apps against common and critical attacks, provides rate limiting, detects malicious traffic (including bots), and more.

19 lines (18 loc) 821 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) { // Restify v9 and higher is checking that the request handler or middleware has the correct signature. // eslint-disable-next-line @typescript-eslint/no-unused-vars return function wrapped(req, res, next) { 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); }); }; }