-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauthConector.js
More file actions
38 lines (32 loc) · 792 Bytes
/
Copy pathauthConector.js
File metadata and controls
38 lines (32 loc) · 792 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
require('dotenv').config();
const mysql = require('mysql');
const connection = mysql.createPool({
host: process.env.HOST,
user: process.env.USER,
password: process.env.PASSWORD,
database: process.env.DB
});
connection.getConnection((err) => {
if (err) {
console.error('Error connecting to MySQL: ' + err.stack);
return;
}
});
function banco(query, callback) {
try {
connection.query(query, (err, rows) => {
if (rows == []) {
rows = 0;
} try {
return callback(rows[0]["tipo_de_user"]);
} catch {
return callback(0);
}
});
}
catch (err) {
console.log(err);
return callback(0);
}
}
module.exports = banco;