chokepoint
TypeScript icon, indicating that this package has built-in type declarations

1.7.0 • Public • Published

Chokepoint

Chokepoint is a powerful Node.js package designed to streamline HTTP/HTTPS load balancing in your applications. It distributes incoming traffic across multiple nodes using Round Robin algorithm, ensuring optimal resource utilization and enhanced performance.

NPM npm GitHub contributors GitHub last commit (branch) npm

HTTP load balancing

import Chokepoint from "chokepoint";

const nodes = [
  { host: "localhost", port: 8001 },
  { host: "localhost", port: 8002 },
  { host: "localhost", port: 8003 },
];
const chokepoint = new Chokepoint(nodes);

chokepoint.listen(80, () => {
  console.log("Load balancer is running");
});

HTTPS load balancing

import Chokepoint from "chokepoint";

const nodes = [
  { host: "localhost", port: 8001 },
  { host: "localhost", port: 8002 },
  { host: "localhost", port: 8003 },
];
const chokepoint = new Chokepoint(nodes);

// Configure SSL certificate before listen
chokepoint.secure({
  key: fs.readFileSync("./ssl-key.pem"),
  cert: fs.readFileSync("./ssl-cert.pem"),
});

chokepoint.listen(443, () => {
  console.log("Secure load balancer is running");
});

Enable CORS

import Chokepoint from "chokepoint";

const nodes = [
  { host: "localhost", port: 8001 },
  { host: "localhost", port: 8002 },
  { host: "localhost", port: 8003 },
];
const chokepoint = new Chokepoint(nodes);

// Enable CORS for your request origins before listen
chokepoint.cors(["https://example.com"]);

chokepoint.listen(80, () => {
  console.log("Load balancer is running");
});

🚀 Excited to kickstart this project! Your support means the world to us. Please give us a star ⭐️ on GitHub to show your encouragement and help us grow! Let's build something amazing together! 🌟

Package Sidebar

Install

npm i chokepoint

Weekly Downloads

0

Version

1.7.0

License

MIT

Unpacked Size

10.1 kB

Total Files

14

Last publish

Collaborators

  • renjithvk