http-proxy-middleware
Advanced tools
Comparing version 1.1.0 to 1.1.1-alpha.1
# Changelog | ||
## next | ||
- fix(option): optional `target` when `router` is used ([#512](https://github.com/chimurai/http-proxy-middleware/pull/512)) | ||
## [v1.1.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.1.0) | ||
@@ -4,0 +8,0 @@ |
@@ -1,5 +0,6 @@ | ||
import { Options } from './types'; | ||
export declare function createConfig(context: any, opts?: any): { | ||
context: any; | ||
import { Filter, Options } from './types'; | ||
export declare type Config = { | ||
context: Filter; | ||
options: Options; | ||
}; | ||
export declare function createConfig(context: any, opts?: Options): Config; |
@@ -37,3 +37,3 @@ "use strict"; | ||
configureLogger(config.options); | ||
if (!config.options.target) { | ||
if (!config.options.target && !config.options.router) { | ||
throw new Error(errors_1.ERRORS.ERR_CONFIG_FACTORY_TARGET_MISSING); | ||
@@ -40,0 +40,0 @@ } |
@@ -1,1 +0,2 @@ | ||
export declare function match(context: any, uri: any, req: any): any; | ||
import type { Filter, Request } from './types'; | ||
export declare function match(context: Filter, uri: string, req: Request): boolean; |
@@ -1,2 +0,4 @@ | ||
export declare function init(proxy: any, option: any): void; | ||
export declare function getHandlers(options: any): any; | ||
import type { Options } from './types'; | ||
import type * as httpProxy from 'http-proxy'; | ||
export declare function init(proxy: httpProxy, option: Options): void; | ||
export declare function getHandlers(options: Options): any; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getHandlers = exports.init = void 0; | ||
const camelcase = require("camelcase"); | ||
const logger_1 = require("./logger"); | ||
@@ -17,12 +16,18 @@ const logger = logger_1.getInstance(); | ||
// https://github.com/nodejitsu/node-http-proxy#listening-for-proxy-events | ||
const proxyEvents = ['error', 'proxyReq', 'proxyReqWs', 'proxyRes', 'open', 'close']; | ||
const proxyEventsMap = { | ||
error: 'onError', | ||
proxyReq: 'onProxyReq', | ||
proxyReqWs: 'onProxyReqWs', | ||
proxyRes: 'onProxyRes', | ||
open: 'onOpen', | ||
close: 'onClose', | ||
}; | ||
const handlers = {}; | ||
for (const event of proxyEvents) { | ||
for (const [eventName, onEventName] of Object.entries(proxyEventsMap)) { | ||
// all handlers for the http-proxy events are prefixed with 'on'. | ||
// loop through options and try to find these handlers | ||
// and add them to the handlers object for subscription in init(). | ||
const eventName = camelcase('on ' + event); | ||
const fnHandler = options ? options[eventName] : null; | ||
const fnHandler = options ? options[onEventName] : null; | ||
if (typeof fnHandler === 'function') { | ||
handlers[event] = fnHandler; | ||
handlers[eventName] = fnHandler; | ||
} | ||
@@ -29,0 +34,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Filter, RequestHandler, Options } from './types'; | ||
import type { Filter, RequestHandler, Options } from './types'; | ||
export declare class HttpProxyMiddleware { | ||
@@ -3,0 +3,0 @@ private logger; |
{ | ||
"name": "http-proxy-middleware", | ||
"version": "1.1.0", | ||
"version": "1.1.1-alpha.1", | ||
"description": "The one-liner node.js proxy middleware for connect, express and browser-sync", | ||
@@ -53,3 +53,3 @@ "main": "dist/index.js", | ||
"@commitlint/config-conventional": "^12.0.1", | ||
"@types/express": "^4.17.3", | ||
"@types/express": "4.17.7", | ||
"@types/is-glob": "^4.0.1", | ||
@@ -56,0 +56,0 @@ "@types/jest": "^26.0.22", |
@@ -503,2 +503,3 @@ # http-proxy-middleware | ||
- [express](https://www.npmjs.com/package/express) | ||
- [fastify](https://www.npmjs.com/package/fastify) | ||
- [browser-sync](https://www.npmjs.com/package/browser-sync) | ||
@@ -505,0 +506,0 @@ - [lite-server](https://www.npmjs.com/package/lite-server) |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
64352
791
545
1
0