1.0.8 • Published 5 years ago
express-server-toolbox v1.0.8
express-server-toolbox
Includes
- DDOS, Spam & Brute force protection
- Proxy server for all request/response types
- 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;
}
});