-
Notifications
You must be signed in to change notification settings - Fork 0
/
connectionTest.js
42 lines (39 loc) · 952 Bytes
/
connectionTest.js
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
//Imports and Requirements
var restify = require('restify');
var Sequelize = require('sequelize');
//Database config
var env = "dev";
var config = require('./config.json')[env];
var password = config.password ? config.password : null;
//initiate database connection
var sequelize = new Sequelize(
config.database,
config.user,
config.password,
{
dialect: config.dialect,
port: config.port,
host: config.host,
logging: console.log,
define: {
timestamps: false
},
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
}
}
);
//Authenticate Database connection
sequelize
.authenticate()
.then(function(err) {
console.log('Connection has been established successfully.');
process.exit(0);
})
.catch(function (err) {
console.log('Unable to connect to the database:', err);
process.exit(1);
});