mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[http-proxy] update TargetUrl (#41321)
* [http-proxy] update TargetUrl * test + lint * more * add the contrib * typo
This commit is contained in:
parent
77b0d0fd9a
commit
7c20e8a02f
@ -25,10 +25,31 @@ http.createServer((req, res) => {
|
||||
proxy.web(req, res);
|
||||
});
|
||||
|
||||
const newProxy = HttpProxy.createProxyServer({
|
||||
const newProxyDefault = HttpProxy.createProxyServer({
|
||||
target: {
|
||||
host: 'localhost',
|
||||
port: '9015'
|
||||
},
|
||||
ws: true
|
||||
});
|
||||
|
||||
const newProxyUrl = HttpProxy.createProxyServer({
|
||||
target: 'http://localhost:9015'
|
||||
});
|
||||
|
||||
const newProxyComplete = HttpProxy.createProxyServer({
|
||||
target: {
|
||||
protocol: 'http:',
|
||||
host: 'localhost',
|
||||
port: 9015,
|
||||
pfx: Buffer.from('foobar'),
|
||||
hostname: 'localhost.com',
|
||||
socketPath: '/foo',
|
||||
passphrase: 'password',
|
||||
key: 'my-key',
|
||||
cert: 'my-cert',
|
||||
ca: 'my-ca',
|
||||
ciphers: 'my-ciphers',
|
||||
secureProtocol: 'my-secure-protocol'
|
||||
}
|
||||
});
|
||||
|
||||
20
types/http-proxy/index.d.ts
vendored
20
types/http-proxy/index.d.ts
vendored
@ -4,6 +4,7 @@
|
||||
// Florian Oellerich <https://github.com/Raigen>
|
||||
// Daniel Schmidt <https://github.com/DanielMSchmidt>
|
||||
// Jordan Abreu <https://github.com/jabreu610>
|
||||
// Samuel Bodin <https://github.com/bodinsamuel>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
@ -16,8 +17,25 @@ import * as events from "events";
|
||||
import * as url from "url";
|
||||
import * as stream from "stream";
|
||||
|
||||
type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed;
|
||||
|
||||
type ProxyTargetUrl = string | Partial<url.Url>;
|
||||
|
||||
interface ProxyTargetDetailed {
|
||||
host: string;
|
||||
port: number;
|
||||
protocol?: string;
|
||||
hostname?: string;
|
||||
socketPath?: string;
|
||||
key?: string;
|
||||
passphrase?: string;
|
||||
pfx?: Buffer | string;
|
||||
cert?: string;
|
||||
ca?: string;
|
||||
ciphers?: string;
|
||||
secureProtocol?: string;
|
||||
}
|
||||
|
||||
type ErrorCallback = (
|
||||
err: Error,
|
||||
req: http.IncomingMessage,
|
||||
@ -169,7 +187,7 @@ declare class Server extends events.EventEmitter {
|
||||
declare namespace Server {
|
||||
interface ServerOptions {
|
||||
/** URL string to be parsed with the url module. */
|
||||
target?: ProxyTargetUrl;
|
||||
target?: ProxyTarget;
|
||||
/** URL string to be parsed with the url module. */
|
||||
forward?: ProxyTargetUrl;
|
||||
/** Object to be passed to http(s).request. */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user