express-http-proxy
Advanced tools
Comparing version 0.0.1 to 0.1.0
{ | ||
"name": "express-http-proxy", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "http proxy middleware for express", | ||
@@ -27,6 +27,11 @@ "main": "index.js", | ||
}, | ||
"devDependencies": {}, | ||
"devDependencies": { | ||
"supertest": "^0.13.0", | ||
"express": "^4.3.1" | ||
}, | ||
"dependencies": { | ||
"mocha": "^1.19.0" | ||
"mocha": "^1.19.0", | ||
"type-is": "^1.2.0", | ||
"raw-body": "^1.1.6" | ||
} | ||
} | ||
} |
# 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) | ||
<!-- description --> | ||
Express proxy middleware to forward request to another host and pass response back | ||
## Install | ||
@@ -14,5 +15,47 @@ | ||
```js | ||
var express_http_proxy = require('express-http-proxy'); | ||
var proxy = require('express-http-proxy'); | ||
var app = require('express')(); | ||
app.use('/proxy', proxy('www.google.com', { | ||
forwardPath: function(req, res) { | ||
return require('url').parse(req.url).path; | ||
} | ||
})); | ||
``` | ||
If you only want to proxy get request | ||
```js | ||
app.use('/proxy', proxy('www.google.com', { | ||
filter: function(req, res) { | ||
return req.method == 'GET'; | ||
}, | ||
forwardPath: function(req, res) { | ||
return require('url').parse(req.url).path; | ||
} | ||
})); | ||
``` | ||
You can also intercept the response get by proxy before send it back to the client: | ||
```js | ||
app.use('/proxy', proxy('www.google.com', { | ||
forwardPath: function(req, res) { | ||
return require('url').parse(req.url).path; | ||
}, | ||
intercept: function(data, req, res, callback) { | ||
data = JSON.parse(data.toString('utf8')); | ||
callback(null, JSON.stringify(data.obj)); | ||
} | ||
})); | ||
``` | ||
## Licence | ||
@@ -19,0 +62,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
9692
9
187
63
3
2
+ Addedraw-body@^1.1.6
+ Addedtype-is@^1.2.0
+ Addedbytes@1.0.0(transitive)
+ Addediconv-lite@0.4.8(transitive)
+ Addedmedia-typer@0.3.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedraw-body@1.3.4(transitive)
+ Addedtype-is@1.6.18(transitive)