Skip to content

Commit 1564779

Browse files
authored
Merge pull request #210 from StatelessStudio/v3.3.4
[3.3.4] Mar-15-2021
2 parents 2283feb + 463e3b2 commit 1564779

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# PointyApi Changelog
22

3+
## [3.3.4] Mar-15-2021
4+
5+
### Fixes
6+
- Use SSL for postgres production connections
7+
38
## [3.3.3]
49

510
### Fixes

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pointyapi",
3-
"version": "3.3.3",
3+
"version": "3.3.4",
44
"author": "stateless-studio",
55
"license": "MIT",
66
"scripts": {

src/database/postgres.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ export class PointyPostgres extends BaseDb {
1717
public connect(options?: string | Object): Promise<Connection> {
1818
return new Promise(async (accept, reject) => {
1919
let pgOptions: any;
20+
let useSSL = false;
2021

2122
if (process.env.DATABASE_URL) {
2223
// Live
2324
pgOptions = PostgressConnectionStringParser.parse(
2425
process.env.DATABASE_URL
2526
);
2627
pgOptions.type = 'postgres';
28+
useSSL = true;
2729

2830
this.logger('Using production database');
2931
this.logger(
@@ -52,8 +54,7 @@ export class PointyPostgres extends BaseDb {
5254
this.shouldSync = true;
5355
}
5456

55-
// Create connection
56-
const conn = await createConnection(<ConnectionOptions>{
57+
options = {
5758
name: this.connectionName,
5859
type: process.env.TYPEORM_DRIVER_TYPE || pgOptions.type,
5960
driver: process.env.TYPEORM_DRIVER_TYPE || pgOptions.type,
@@ -67,7 +68,16 @@ export class PointyPostgres extends BaseDb {
6768
uuidExtension: pgOptions.uuidExtension
6869
? pgOptions.uuidExtension
6970
: 'pgcrypto'
70-
}).catch((error) => {
71+
};
72+
73+
if (useSSL) {
74+
options['ssl'] = {
75+
rejectUnauthorized: false
76+
};
77+
}
78+
79+
// Create connection
80+
const conn = await createConnection(<ConnectionOptions>options).catch((error) => {
7181
reject(error);
7282
return false;
7383
});

0 commit comments

Comments
 (0)