Skip to content

Commit 3e88073

Browse files
committed
Only require SSL DB connection in production
When running the bot locally, for development, SSL is an unnecessary extra setup step that makes it harder to get started.
1 parent 15bbbf0 commit 3e88073

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/db.ts

+14-6
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,26 @@ let db: Connection | undefined;
88
export async function getDB() {
99
if (db) return db;
1010

11+
// Require ssl in production
12+
const extra_opts =
13+
process.env.NODE_ENV === 'production'
14+
? {
15+
ssl: true,
16+
extra: {
17+
ssl: {
18+
rejectUnauthorized: false,
19+
},
20+
},
21+
}
22+
: {};
23+
1124
db = await createConnection({
1225
type: 'postgres',
1326
url: dbUrl,
1427
synchronize: true,
1528
logging: false,
1629
entities: [RepUser, RepGive, HelpUser],
17-
ssl: true,
18-
extra: {
19-
ssl: {
20-
rejectUnauthorized: false,
21-
},
22-
},
30+
...extra_opts,
2331
});
2432
console.log('Connected to DB');
2533
return db;

0 commit comments

Comments
 (0)