forked from Varun-Hegde/Conduit_NodeJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbConnection.js
More file actions
43 lines (37 loc) · 1.06 KB
/
dbConnection.js
File metadata and controls
43 lines (37 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const {Sequelize} = require('sequelize')
//LOCAL CONNECTION
/* const sequelize = new Sequelize('conduit','root','password',{
dialect: 'mysql',
host:'localhost',
logging: false
}); */
//AMAZON RDS CONNECTION
/* const sequelize = new Sequelize('conduit1',process.env.USER_NAME,process.env.PASSWORD,{
dialect: 'mysql',
host:process.env.DB_HOST,
logging: false,
port: 3306
});
*/
const sequelize = new Sequelize('d6rk5ijgmvcf6q',process.env.USER_NAME,process.env.PASSWORD,{
dialect: 'postgres',
host: process.env.DB_HOST,
logging: false,
port: 5432,
dialectOptions: {
ssl: {
require: true,
rejectUnauthorized: false // <<<<<<< YOU NEED THIS
}
}
});
const checkConnection =async () => {
try {
await sequelize.authenticate();
console.log('Connection has been established successfully.');
} catch (error) {
console.error('Unable to connect to the database:', error);
}
}
checkConnection()
module.exports = sequelize