Node.js (hapi)
Requirements
Installation & Configuration
1
Install Zen Firewall by Aikido
npm install --save-exact @aikidosec/firewallyarn add --exact @aikidosec/firewallpnpm add --save-exact @aikidosec/firewallrequire("@aikidosec/firewall");
const Hapi = require("@hapi/hapi");
const server = Hapi.server({ port: 3000, host: "localhost" });import "@aikidosec/firewall";
import Hapi from "@hapi/hapi";
const server = Hapi.server({ port: 3000, host: "localhost" });2
4
Enable Rate limiting and User blocking
const Zen = require("@aikidosec/firewall");
// Optional, if you want to use user based rate limiting or block specific users
server.ext("onRequest", (request, h) => {
Zen.setUser({ id: "123", name: "John Doe" });
return h.continue;
});
// Call this after auth middleware, as early as possible in the middleware stack
Zen.addHapiMiddleware(server);5
Setup rate limiting in the dashboard



You are rate limited by Aikido firewall. (Your IP: 1.2.3.4)Last updated
Was this helpful?
