Skip to content

Commit 19aba46

Browse files
committed
fix #4 -- add typescript typings
1 parent bfa226f commit 19aba46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+70
-38
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tes.js
88
npm-debug.log
99
.nyc_output
1010
coverage
11-
tsconfig.tsbuildinfo
1211
dist
1312
*.sage-chat
1413
*.term
14+
*.tsbuildinfo

.tsconfig-bootstrap.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
preset: "ts-jest",
33
testEnvironment: "node",
4-
setupFiles: ["./test/setup.js"],
4+
setupFiles: ["./lib/test/setup.js"],
55
testMatch: ["**/?(*.)+(spec|test).ts?(x)"],
66
};

lib/http-proxy/common.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export interface Outgoing extends Outgoing0 {
1515
method?: any;
1616
rejectUnauthorized?: boolean;
1717
path?: string;
18-
headers: { [header: string]: string | string[] | undefined };
18+
headers: { [header: string]: string | string[] | undefined } & {
19+
overwritten?: boolean;
20+
};
1921
}
2022

2123
// If we allow this header and a user sends it with a request,

lib/http-proxy/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface ProxyTargetDetailed {
2525
}
2626
export type ProxyType = "ws" | "web";
2727
export type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed;
28-
export type ProxyTargetUrl = URL | string;
28+
export type ProxyTargetUrl = URL | string | { port: number; host: string };
2929

3030
export interface ServerOptions {
3131
// NOTE: `options.target and `options.forward` cannot be both missing when the
@@ -145,10 +145,7 @@ export class ProxyServer extends EventEmitter {
145145
}
146146

147147
if (!requestOptions.target && !requestOptions.forward) {
148-
this.emit(
149-
"error",
150-
new Error("Must set target or forward"),
151-
);
148+
this.emit("error", new Error("Must set target or forward"));
152149
return;
153150
}
154151

lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export { numOpenSockets } from "./http-proxy/passes/ws-incoming";
1717
* @api public
1818
*/
1919

20-
function createProxyServer(options: ServerOptions): ProxyServer {
20+
function createProxyServer(options: ServerOptions = {}): ProxyServer {
2121
return new ProxyServer(options);
2222
}
2323

test/balancer/simple-balancer-with-websockets.test.ts renamed to lib/test/balancer/simple-balancer-with-websockets.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe("A simple round-robin load balancer that supports websockets", () => {
6666
);
6767

6868
proxyPort = await getPort();
69-
servers.proxy = httpProxy.createProxyServer();
69+
servers.proxy = httpProxy.createProxyServer({});
7070
let i = 0;
7171
function nextProxy() {
7272
i = (i + 1) % addresses.length;

test/balancer/simple-balancer.test.ts renamed to lib/test/balancer/simple-balancer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe("A simple round-robin load balancing strategy.", () => {
4646
let proxyPort;
4747
it("creates the round robin proxy server", async () => {
4848
proxyPort = await getPort();
49-
const proxy = httpProxy.createServer();
49+
const proxy = httpProxy.createServer({});
5050
let i = 0;
5151
servers.proxy = http
5252
.createServer((req, res) => {
File renamed without changes.

0 commit comments

Comments
 (0)