Total Complexity | 3 |
Complexity/F | 3 |
Lines of Code | 28 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import log from './log'; |
||
2 | import * as mysql from 'mysql'; |
||
3 | import configuration from './config'; |
||
4 | var config = configuration; |
||
5 | |||
6 | function mysql_connection(): null | mysql.Connection { |
||
7 | var result = null; |
||
8 | if (config.hasOwnProperty('database')) { |
||
9 | const database = config.database; |
||
10 | var con = mysql.createConnection({ |
||
11 | host: database.host, |
||
12 | user: database.user, |
||
13 | password: database.pass, |
||
14 | port: Number(database.port), |
||
15 | database: database.dbname, |
||
16 | }); |
||
17 | con.connect(function (err: any) { |
||
18 | if (err) { |
||
19 | log.log(log.error(err)); |
||
20 | } else { |
||
21 | log.log(log.success('Connected!')); |
||
22 | result = con; |
||
23 | } |
||
24 | }); |
||
25 | } |
||
26 | return result; |
||
27 | } |
||
28 | |||
29 | //export = mysql_connection; |
||
31 |