Skip to content

Commit

Permalink
Add stream factory method type
Browse files Browse the repository at this point in the history
  • Loading branch information
ruyadorno committed May 17, 2023
1 parent 072792e commit 73181a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions types/pg/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for pg 8.6
// Type definitions for pg 8.10
// Project: https://github.com/brianc/node-postgres
// Definitions by: Phips Peter <https://github.com/pspeter3>, Ravi van Rooijen <https://github.com/HoldYourWaffle>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
Expand All @@ -21,7 +21,7 @@ export interface ClientConfig {
host?: string | undefined;
connectionString?: string | undefined;
keepAlive?: boolean | undefined;
stream?: stream.Duplex | undefined;
stream?: () => stream.Duplex | stream.Duplex | undefined;
statement_timeout?: false | number | undefined;
ssl?: boolean | ConnectionOptions | undefined;
query_timeout?: number | undefined;
Expand Down
9 changes: 9 additions & 0 deletions types/pg/pg-tests.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { connect } from 'net';
import { types, Client, CustomTypesConfig, QueryArrayConfig, Pool, DatabaseError } from 'pg';
import TypeOverrides = require('pg/lib/type-overrides');
import { NoticeMessage } from 'pg-protocol/dist/messages';
Expand Down Expand Up @@ -305,6 +306,14 @@ c = new Client({
connectionTimeoutMillis: 1000, // connection timeout optionally specified
});

// using custom socket factory method
c = new Client({
stream: () => connect({
host: 'my.database-server.com',
port: 5334,
}),
});

const dynamicPasswordSync = new Client({
password: () => 'sync-secret',
});
Expand Down

0 comments on commit 73181a8

Please sign in to comment.