-
Notifications
You must be signed in to change notification settings - Fork 852
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
265 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { HttpProxyMiddleware } from './http-proxy-middleware'; | ||
import { Filter, Options } from './types'; | ||
|
||
function proxy(context, opts) { | ||
const { middleware } = new HttpProxyMiddleware(context, opts); | ||
function middleware(context: Filter | Options, options?: Options) { | ||
const { middleware } = new HttpProxyMiddleware(context, options); | ||
return middleware; | ||
} | ||
|
||
export = proxy; | ||
export = middleware; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import express from 'express'; | ||
import http from 'http'; | ||
import httpProxy from 'http-proxy'; | ||
import net from 'net'; | ||
|
||
export interface IRequest extends express.Request {} | ||
export interface IResponse extends express.Response {} | ||
|
||
export interface IRequestHandler extends express.RequestHandler { | ||
upgrade?: (req: IRequest, socket: net.Socket, head: any) => void; | ||
} | ||
|
||
export type Filter = string | string[] | ((pathname: string, req: IRequest) => boolean); | ||
|
||
export interface Options extends httpProxy.ServerOptions { | ||
pathRewrite?: | ||
| { [regexp: string]: string } | ||
| ((path: string, req: IRequest) => string); | ||
router?: | ||
| { [hostOrPath: string]: string } | ||
| ((req: IRequest) => string) | ||
| ((req: IRequest) => Promise<string>); | ||
logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent'; | ||
logProvider?(provider: LogProvider): LogProvider; | ||
|
||
onError?(err: Error, req: IRequest, res: IResponse): void; | ||
onProxyRes?( | ||
proxyRes: http.ServerResponse, | ||
req: IRequest, | ||
res: IResponse | ||
): void; | ||
onProxyReq?( | ||
proxyReq: http.ClientRequest, | ||
req: IRequest, | ||
res: IResponse | ||
): void; | ||
onProxyReqWs?( | ||
proxyReq: http.ClientRequest, | ||
req: IRequest, | ||
socket: net.Socket, | ||
options: httpProxy.ServerOptions, | ||
head: any | ||
): void; | ||
onOpen?(proxySocket: net.Socket): void; | ||
onClose?(res: IResponse, socket: net.Socket, head: any): void; | ||
} | ||
|
||
interface LogProvider { | ||
log: Logger; | ||
debug?: Logger; | ||
info?: Logger; | ||
warn?: Logger; | ||
error?: Logger; | ||
} | ||
|
||
type Logger = (...args: any[]) => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.