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

heroku-proxy

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

heroku-proxy - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

46

index.js
'use strict';
/**
* HerokuProxy proxies requests to the Heroku API. It is meant to be used in
* conjunction with
* [heroku-bouncer](https://github.com/jclem/node-heroku-bouncer), which will
* add the necessary authentication information to the incoming request.
*
* @class HerokuProxy
*/
var express = require('express');

@@ -7,4 +16,25 @@ var logfmt = require('logfmt');

module.exports = function(options) {
options || (options = {});
/**
* @method createProxy
* @param {Object} options options for configuring the proxy middleware
* @param {String} [options.prefix] a prefix to look for API requests under,
* such as `'api'` when an apps request might go to `'/api/apps'`
* @param {String} [options.hostname='api.heroku.com'] the hostname for the
* Heroku API
* @param {Array} [options.whitelistHeader=[]] an array of headers, in addition
* to the default whitelisted ones, to pass through to the API for each
* request
* @param {Object} [options.headerTransforms={}] an object of request headers as
* keys and as values the headers they should be transformed into before being
* proxied (e.g. `{ 'x-range': 'range' }`
* @param {Number} [options.port=443] the port on the API to send requests to
* @param {String} [options.protocol='https'] the protocol to use for the
* proxied requests
* @param {Boolean} [options.log] if `true`, request details such as elapsed
* time and path requested will be logged
* @return {Function} a piece of middleware which will look for API requests
* and proxy them
*/
module.exports = function createProxy(options) {
options = options || {};
setOptions(options);

@@ -43,3 +73,5 @@

for (var header in proxyRes.headers) {
res.setHeader(header, proxyRes.headers[header]);
if (proxyRes.headers.hasOwnProperty(header)) {
res.setHeader(header, proxyRes.headers[header]);
}
}

@@ -84,10 +116,2 @@

}, {});
return headersWhitelist.reduce(function(headers, header) {
if (headersWhitelist.indexOf(header) >= -1 && req.headers.hasOwnProperty(header)) {
headers[header] = req.headers[header];
}
return headers;
}, {});
}

@@ -94,0 +118,0 @@

{
"name": "heroku-proxy",
"version": "1.4.0",
"version": "1.4.1",
"description": "a heroku proxy",

@@ -31,3 +31,25 @@ "main": "index.js",

"request": "~2.34.0"
},
"jshintConfig": {
"eqeqeq" : true,
"forin" : true,
"globalstrict": true,
"immed" : true,
"indent" : 2,
"latedef" : "nofunc",
"newcap" : true,
"noarg" : true,
"quotmark" : "single",
"strict" : true,
"trailing" : true,
"undef" : true,
"unused" : true,
"globals" : {
"Buffer" : false,
"describe": false,
"it" : false,
"module" : false,
"require" : false
}
}
}

@@ -48,2 +48,3 @@ # heroku-proxy

| -------- | ------ | ------- |
| log | Log request details | `false` |
| hostname | The hostname to proxy requests to | `api.heroku.com` |

@@ -50,0 +51,0 @@ | port | The port on API host | `443` |

@@ -5,3 +5,2 @@ 'use strict';

var http = require('http');
var proxy = require('../../index');
var app = express();

@@ -12,3 +11,5 @@ var server = http.createServer(app);

for (var header in req.headers) {
res.setHeader(header, req.headers[header]);
if (req.headers.hasOwnProperty(header)) {
res.setHeader(header, req.headers[header]);
}
}

@@ -15,0 +16,0 @@

'use strict';
var request = require('request');
var should = require('should');
require('should');

@@ -69,3 +69,3 @@ describe('proxy', function() {

if (err) throw err;
res.headers['bar'].should.eql('bar');
res.headers.bar.should.eql('bar');
done();

@@ -81,4 +81,4 @@ });

if (err) throw err;
res.headers['range'].should.eql('foofyfoofoo');
res.headers['bar'].should.eql('barbybarbar');
res.headers.range.should.eql('foofyfoofoo');
res.headers.bar.should.eql('barbybarbar');
done();

@@ -94,3 +94,3 @@ });

var expectedHeader = 'Basic ' + (new Buffer(':my-token').toString('base64'));
res.headers['authorization'].should.eql(expectedHeader);
res.headers.authorization.should.eql(expectedHeader);
done();

@@ -97,0 +97,0 @@ });

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