Skip to content

Commit ad7df4c

Browse files
committed
2 parents 747b3ba + 1651d88 commit ad7df4c

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

index.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,30 @@ const flash = require('express-flash');
1515
const CategoryService = require('./services/category-service');
1616
const ProductService = require('./services/product-service');
1717
const UserService = require('./services/user-service');
18-
1918
const pgp = require('pg-promise')();
2019

21-
let useSSL = false;
22-
let local = process.env.LOCAL || false;
23-
if (process.env.DATABASE_URL && !local){
24-
useSSL = true;
20+
const DATABASE_URL= process.env.DATABASE_URL || "postgresql://localhost:5432/my_products_list";
21+
22+
const config = {
23+
connectionString : DATABASE_URL
24+
}
25+
26+
if (process.env.NODE_ENV == 'production') {
27+
config.ssl = {
28+
rejectUnauthorized : false
29+
}
2530
}
26-
const connectionString = process.env.DATABASE_URL || 'postgresql://localhost:5432/my_products_list';
2731

28-
const db = pgp(connectionString);
32+
const db = pgp(config);
33+
34+
// let useSSL = false;
35+
// let local = process.env.LOCAL || false;
36+
// if (process.env.DATABASE_URL && !local){
37+
// useSSL = true;
38+
// }
39+
// const connectionString = process.env.DATABASE_URL || 'postgresql://localhost:5432/my_products_list';
40+
41+
// const db = pgp(connectionString);
2942

3043
const categoryService = CategoryService(db);
3144
const productService = ProductService(db);

0 commit comments

Comments
 (0)