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

http-proxy-middleware

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-proxy-middleware - npm Package Compare versions

Comparing version 0.21.0-beta.2 to 0.21.0-beta.3

2

CHANGELOG.md

@@ -5,4 +5,6 @@ # Changelog

- feat(http-proxy): bump to v1.18.0
- feat: async router ([#379](https://github.com/chimurai/http-proxy-middleware/issues/335)) ([LiranBri](https://github.com/LiranBri))
- feat(typescript): types support ([#369](https://github.com/chimurai/http-proxy-middleware/pull/369))
- feat: async pathRewrite ([#397](https://github.com/chimurai/http-proxy-middleware/pull/397)) ([rsethc](https://github.com/rsethc))

@@ -9,0 +11,0 @@ ## [v0.20.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.20.0)

13

dist/http-proxy-middleware.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

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

yield this.applyRouter(req, newProxyOptions);
this.applyPathRewrite(req, this.pathRewriter);
yield this.applyPathRewrite(req, this.pathRewriter);
// debug logging for both http(s) and websockets

@@ -114,5 +115,5 @@ if (this.proxyOptions.logLevel === 'debug') {

// rewrite path
this.applyPathRewrite = (req, pathRewriter) => {
this.applyPathRewrite = (req, pathRewriter) => __awaiter(this, void 0, void 0, function* () {
if (pathRewriter) {
const path = pathRewriter(req.url, req);
const path = yield pathRewriter(req.url, req);
if (typeof path === 'string') {

@@ -125,5 +126,5 @@ req.url = path;

}
};
});
this.logError = (err, req, res) => {
const hostname = (req.headers && req.headers.host) || (req.hostname || req.host); // (websocket) || (node0.10 || node 4/5)
const hostname = (req.headers && req.headers.host) || req.hostname || req.host; // (websocket) || (node0.10 || node 4/5)
const target = this.proxyOptions.target.host || this.proxyOptions.target;

@@ -130,0 +131,0 @@ const errorMessage = '[HPM] Error occurred while trying to proxy request %s from %s to %s (%s) (%s)';

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -8,0 +9,0 @@ });

@@ -13,10 +13,7 @@ /// <reference types="node" />

}
export declare type Filter = FilterPath | FilterWildcards | FilterFn;
export declare type FilterFn = (pathname: string, req: IRequest) => boolean;
export declare type FilterPath = string;
export declare type FilterWildcards = string[];
export declare type Filter = string | string[] | ((pathname: string, req: IRequest) => boolean);
export interface Options extends httpProxy.ServerOptions {
pathRewrite?: {
[regexp: string]: string;
} | ((path: string, req: IRequest) => string);
} | ((path: string, req: IRequest) => string) | ((path: string, req: IRequest) => Promise<string>);
router?: {

@@ -23,0 +20,0 @@ [hostOrPath: string]: string;

{
"name": "http-proxy-middleware",
"version": "0.21.0-beta.2",
"version": "0.21.0-beta.3",
"description": "The one-liner node.js proxy middleware for connect, express and browser-sync",

@@ -56,5 +56,5 @@ "main": "dist/index.js",

"@types/is-glob": "^4.0.0",
"@types/jest": "^24.0.15",
"@types/lodash": "^4.14.136",
"@types/micromatch": "^3.1.0",
"@types/jest": "^25.1.2",
"@types/lodash": "^4.14.149",
"@types/micromatch": "^4.0.1",
"@types/node": "^12.6.2",

@@ -66,16 +66,16 @@ "browser-sync": "^2.26.7",

"husky": "^3.0.0",
"jest": "^24.5.0",
"open": "^6.4.0",
"prettier": "^1.18.2",
"ts-jest": "^24.0.0",
"tslint": "^5.18.0",
"jest": "^25.1.0",
"open": "^7.0.2",
"prettier": "^1.19.1",
"ts-jest": "^25.2.0",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.5.3",
"typescript": "^3.7.5",
"ws": "^7.1.0"
},
"dependencies": {
"@types/http-proxy": "^1.17.0",
"http-proxy": "^1.17.0",
"@types/http-proxy": "^1.17.3",
"http-proxy": "^1.18.0",
"is-glob": "^4.0.1",
"lodash": "^4.17.14",
"lodash": "^4.17.15",
"micromatch": "^4.0.2"

@@ -82,0 +82,0 @@ },

@@ -202,2 +202,10 @@ # http-proxy-middleware

pathRewrite: function (path, req) { return path.replace('/api', '/base/api') }
// custom rewriting, returning Promise
pathRewrite: async function (path, req) {
var should_add_something = await httpRequestToDecideSomething(path);
if (should_add_something) path += "something";
return path;
}
```

@@ -244,3 +252,3 @@

function logProvider(provider) {
var logger = new (require('winston')).Logger();
var logger = new (require('winston').Logger)();

@@ -506,2 +514,2 @@ var myCustomProvider = {

Copyright (c) 2015-2019 Steven Chim
Copyright (c) 2015-2020 Steven Chim
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