-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnection.js
More file actions
39 lines (31 loc) · 841 Bytes
/
connection.js
File metadata and controls
39 lines (31 loc) · 841 Bytes
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
var mysql = require('mysql');
//debug variables
var debugFlags = require('./feature_flags.js');
var isDebug = debugFlags.isDebugMode;
//Make a database connection
function GetConnection(){
return new Promise((resolve) => {
setTimeout(() => {
if (isDebug)
{
console.log("ok!");
resolve("debug");
}
else
{
var connection = mysql.createConnection({
host : process.env.MYSQLHOST,
user : process.env.MYSQLUSER,
password : process.env.MYSQLPW,
database : process.env.MYSQLPLAYERDB
});
connection.connect();
console.log("connected!");
resolve(connection);
}
}, 5000);
});
};
module.exports = {
connection : GetConnection()
};