Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-http-proxy

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-http-proxy - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

4

index.js

@@ -34,3 +34,3 @@ var assert = require('assert');

/**
* intercept(data, res, req, function(err, json));
* intercept(targetResponse, data, res, req, function(err, json));
*/

@@ -97,3 +97,3 @@ var intercept = options.intercept;

if (intercept) {
intercept(rspData, req, res, function(err, rspd, sent) {
intercept(rsp, rspData, req, res, function(err, rspd, sent) {
if (err) {

@@ -100,0 +100,0 @@ return next(err);

{
"name": "express-http-proxy",
"version": "0.3.1",
"version": "0.4.0",
"description": "http proxy middleware for express",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -43,3 +43,3 @@ # express-http-proxy [![NPM version](https://badge.fury.io/js/express-http-proxy.svg)](http://badge.fury.io/js/express-http-proxy) [![Build Status](https://travis-ci.org/villadora/express-http-proxy.svg?branch=master)](https://travis-ci.org/villadora/express-http-proxy) [![Dependency Status](https://gemnasium.com/villadora/express-http-proxy.svg)](https://gemnasium.com/villadora/express-http-proxy)

You can also intercept the response get by proxy before send it back to the client, or change the request options before it get sent to target:
You can also intercept the response before sending it back to the client, or change the request options before it is sent to the target:

@@ -51,3 +51,4 @@ ```js

},
intercept: function(data, req, res, callback) {
intercept: function(rsp, data, req, res, callback) {
// rsp - original response from the target
data = JSON.parse(data.toString('utf8'));

@@ -66,3 +67,7 @@ callback(null, JSON.stringify(data));

## Release Notes
| Release | Notes |
| --- | --- |
| 0.4.0 | Signature of `intercept` callback changed from `function(data, req, res, callback)` to `function(rsp, data, req, res, callback)` where `rsp` is the original response from the target |

@@ -69,0 +74,0 @@ ## Licence

@@ -52,3 +52,3 @@ var assert = require('assert');

app.use(proxy('httpbin.org', {
intercept: function(data, req, res, cb) {
intercept: function(rsp, data, req, res, cb) {
data = JSON.parse(data.toString('utf8'));

@@ -69,6 +69,21 @@ data.intercepted = true;

it('test intercept original response', function(done) {
var app = express();
app.use(proxy('httpbin.org', {
intercept: function(rsp, data, req, res, cb) {
assert(rsp.connection);
assert(rsp.socket);
assert(rsp.headers);
assert(rsp.headers['content-type']);
done();
}
}));
request(app).get('/').end();
});
it('test intercept on html response',function(done) {
var app = express();
app.use(proxy('httpbin.org', {
intercept: function(data, req, res, cb) {
intercept: function(rsp, data, req, res, cb) {
data = data.toString().replace('Oh','<strong>Hey</strong>');

@@ -92,3 +107,3 @@ assert(data !== "");

app.use(proxy('https://api.github.com', {
intercept: function(data, req, res, cb) {
intercept: function(rsp, data, req, res, cb) {
var Iconv = require('iconv').Iconv;

@@ -95,0 +110,0 @@ var iconv = new Iconv('UTF-8', 'utf8');

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