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.

46 lines (45 loc) 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Restify = void 0; const wrapRequestHandler_1 = require("./restify/wrapRequestHandler"); const wrapExport_1 = require("../agent/hooks/wrapExport"); class Restify { wrapArgs(args) { return args.map((arg) => { // Ignore non-function arguments if (typeof arg !== "function") { return arg; } return (0, wrapRequestHandler_1.wrapRequestHandler)(arg); }); } wrap(hooks) { hooks .addPackage("restify") .withVersion("^11.0.0 || ^10.0.0 || ^9.0.0 || ^8.0.0") .onFileRequire("lib/server.js", (exports, pkgInfo) => { // See https://restify.com/docs/server-api/ // We don't need to wrap `server.param(...)` because it uses `server.use(...)` internally // We don't wrap `server.pre(...)` because it's used to modify the request before it reaches the handlers for (const method of [ "get", "head", "post", "put", "patch", "del", "opts", ]) { (0, wrapExport_1.wrapExport)(exports.prototype, method, pkgInfo, { kind: undefined, modifyArgs: (args) => this.wrapArgs(args), }); } (0, wrapExport_1.wrapExport)(exports.prototype, "use", pkgInfo, { kind: undefined, modifyArgs: (args) => this.wrapArgs(args), }); }); } } exports.Restify = Restify;