express-server-toolbox

A firewall / proxy server for NodeJS Express

Usage no npm install needed!

<script type="module">
  import expressServerToolbox from 'https://cdn.skypack.dev/express-server-toolbox';
</script>

README

express-server-toolbox

Includes

  1. DDOS, Spam & Brute force protection
  2. Proxy server for all request/response types
  3. Get and Post parameters get sanitized

Example

// NPM Packages
const expressServerToolkit = require("express-server-toolkit");
const express = require("express");
// Setting up the proxy [Host, Port, Enctype, Timeout]
const ProxyLocalhost = new expressServerToolkit.proxy(
  "localhost",
  8080,
  "http",
  3000
);
// Setting up the DDOS Prevention [MongoDB URI, Max requests per hour]
// Keep in mind that the images/post also count as request, so have at least a limit of a few thousand.
const DDOSPrevention = new expressServerToolkit.DDOSPrevention(
  "mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb",
  5000
);
// Connects the database
DDOSPrevention.connectMongo(err => {
  if (!err) {
    // Prevents DDOS, Bruteforce etc
    app.use(DDOSPrevention.prevent);
    // Express firewall currently only handles sanitize of get/post parameters
    app.use(expressServerToolkit.ExpressFirewall);
    // Handles the requests
    app.use("*", (req, res, next) => {
      // Checks the domain/hostname
      if (req.hostname === "localhost") {
        // Proxy's the request
        ProxyLocalhost.web(req, res, next);
      }
    });
  } else {
    throw err;
  }
});

I am not responsible for security breaches or any other trouble. I am developing this for self education, and it's your choise to use.