Skip to content

Commit

Permalink
Update SSL
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Jan 21, 2024
1 parent 87356cd commit aaa3959
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

## Version History

### v15.8.0

- :rocket: Setup Optional SSL Param for connection settings

### v15.7.0

- :rocket: Input type is now properly typed
Expand Down
15 changes: 13 additions & 2 deletions lib/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ export default class Pool<TSchema extends Record<string, unknown> = Record<strin

constructor(connstr: string, config: {
schema: TSchema
ssl?: {
rejectUnauthorized?: boolean;
};
}) {
const client = postgres(connstr);
const client = postgres(connstr, {
ssl: config.ssl
});

let schema;
if (config.schema) {
Expand Down Expand Up @@ -79,14 +84,20 @@ export default class Pool<TSchema extends Record<string, unknown> = Record<strin
jsonschema?: {
dir: string | URL;
};
ssl?: {
rejectUnauthorized?: boolean;
};
} = {}): Promise<Pool<TSchema>> {
if (!opts.retry) opts.retry = 5;

let pool;
let retry = opts.retry;
do {
try {
pool = new Pool(connstr, { schema });
pool = new Pool(connstr, {
ssl: opts.ssl,
schema
});
await pool.select(sql`NOW()`);
} catch (err) {
console.error(err);
Expand Down

0 comments on commit aaa3959

Please sign in to comment.