Skip to content

Commit

Permalink
Declare correct ws options type (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominykas authored Jan 8, 2025
1 parent c627a42 commit ccf86f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/client.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import type { ClientRequestArgs } from "http";
import type { ClientOptions } from "ws";

// Same as exported type in @hapi/hapi v20
type HTTP_METHODS = 'ACL' | 'BIND' | 'CHECKOUT' | 'CONNECT' | 'COPY' | 'DELETE' | 'GET' | 'HEAD' | 'LINK' | 'LOCK' |
'M-SEARCH' | 'MERGE' | 'MKACTIVITY' | 'MKCALENDAR' | 'MKCOL' | 'MOVE' | 'NOTIFY' | 'OPTIONS' | 'PATCH' | 'POST' |
Expand Down Expand Up @@ -173,7 +176,7 @@ export class Client {
constructor(
url: `ws://${string}` | `wss://${string}`,
options?: {
ws?: string | string[];
ws?: ClientOptions | ClientRequestArgs;
timeout?: number | boolean;
});

Expand Down Expand Up @@ -369,4 +372,4 @@ export class Client {
* `client.connect()`
*/
reauthenticate(auth: ClientConnectOptions['auth']): Promise<unknown>;
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@hapi/iron": "^7.0.1",
"@hapi/teamwork": "^6.0.0",
"@hapi/validate": "^2.0.1",
"@types/ws": "^8.5.13",
"ws": "^8.18.0"
},
"devDependencies": {
Expand Down
8 changes: 7 additions & 1 deletion test/types/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { Client } from '../../lib/client';

const init = () => {

const client = new Client('ws://localhost');
const client = new Client('ws://localhost', {
ws: { // optional
origin: 'http://localhost:12345',
maxPayload: 1000,
headers: { cookie: 'xnes=123' }
}
});

client.connect()

Expand Down

0 comments on commit ccf86f9

Please sign in to comment.