New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dynamic-reverse-proxy

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynamic-reverse-proxy - npm Package Compare versions

Comparing version 0.4.5 to 0.5.0

examples/example.js

38

lib/dynamicProxy.js

@@ -6,4 +6,4 @@ var httpProxy = require("http-proxy"),

this.routes = {};
this.proxy = new httpProxy.RoutingProxy();
this.proxy.on("proxyError", _onProxyError.bind(this));
this.proxy = httpProxy.createProxyServer();
this.proxy.on("error", _onProxyError.bind(this));
};

@@ -34,2 +34,10 @@

DynamicProxy.prototype.registerRoute = function (route) {
route.prefix = route.prefix.replace(/\/+$/, '') || route.prefix;
route.prefix = (route.prefix[0] === "/" ? route.prefix : "/" + route.prefix).toLowerCase();
route.host = "localhost";
this.routes[route.prefix] = route;
this.emit("routeRegistered", route);
};
var _onProxyError = function (error, req, res) {

@@ -63,6 +71,6 @@ this.emit("proxyError", error, req.host, req, res);

var host;
var route;
try {
host = JSON.parse(req.body);
route = JSON.parse(req.body);
}

@@ -78,3 +86,3 @@ catch (e) {

if (!(host && host.prefix && host.port)) {
if (!(route && route.prefix && route.port)) {
this.emit("registerError", new Error("INCOMPLETE_REQUEST"), req, res);

@@ -88,19 +96,14 @@

this.registerRoute(route);
host.prefix = host.prefix.replace(/\/+$/, '') || host.prefix;
host.prefix = (host.prefix[0] === "/" ? host.prefix : "/" + host.prefix).toLowerCase();
host.host = "localhost";
res.statusCode = 200;
this.routes[host.prefix] = host;
res.statusCode = 200;
res.write(JSON.stringify({
message: "Registered.",
host: host.host,
port: host.port,
prefix: host.prefix
host: route.host,
port: route.port,
prefix: route.prefix
}));
res.end();
this.emit("routeRegistered", host);
};

@@ -134,4 +137,5 @@

req.host = Object.create(host);
res.setHeader("x-served-by", "http://" + host.host + ":" + host.port + host.prefix);
this.proxy.proxyRequest(req, res, host);
var target = "http://" + host.host + ":" + host.port;
res.setHeader("x-served-by", target + host.prefix);
this.proxy.web(req, res, { target: target });
};
{
"author": "Andrew Dunkman <andrew@dunkman.org>",
"name": "dynamic-reverse-proxy",
"version": "0.4.5",
"version": "0.5.0",
"repository": {

@@ -9,3 +9,3 @@ "url": "git://github.com/softek/dynamic-reverse-proxy.git"

"dependencies": {
"http-proxy": "0.8.5"
"http-proxy": "1.1.4"
},

@@ -12,0 +12,0 @@ "engines": {

@@ -14,6 +14,6 @@ # dynamic-reverse-proxy

if (req.url.match(/^\/register/i)) {
proxy.registerRouteRequest(req, res);
dynamicProxy.registerRouteRequest(req, res);
}
else {
proxy.proxyRequest(req, res);
dynamicProxy.proxyRequest(req, res);
}

@@ -95,2 +95,2 @@ });

}
```
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc