File tree 3 files changed +19
-24
lines changed
3 files changed +19
-24
lines changed Original file line number Diff line number Diff line change 1
1
const inquirer = require ( 'inquirer' ) ;
2
+ //connection available to all
3
+ const connection = require ( './connection' ) ;
2
4
3
5
const app = { } ;
4
6
5
- app . initialize = ( connection ) => {
6
- //makes connection assessible to the rest of the app
7
- app . connection = connection ;
8
- app . startQuestion ( ( ) => {
9
- app . connection . end ( ) ;
10
- } )
11
-
12
- }
13
-
14
7
app . startQuestion = ( closeConnectionCallback ) => {
15
-
16
8
inquirer . prompt ( {
17
9
type : 'list' ,
18
10
message : 'What action would you like to do?' ,
Original file line number Diff line number Diff line change
1
+ //require packages
2
+ const mysql = require ( "mysql" ) ;
3
+ const mySqlKey = require ( './keys' ) . mySql ;
4
+
5
+ //create MySQL connection
6
+ const connection = mysql . createConnection ( {
7
+ host : "localhost" ,
8
+ port : 3306 ,
9
+ user : "root" ,
10
+ password : mySqlKey ,
11
+ database : "eventonica"
12
+ } ) ;
13
+
14
+ module . exports = connection ;
Original file line number Diff line number Diff line change 1
- //require packages
2
- const mysql = require ( "mysql" ) ;
3
- const mySqlKey = require ( './keys' ) . mySql ;
4
- const app = require ( './app' )
5
-
6
- //create MySQL connection
7
- const connection = mysql . createConnection ( {
8
- host : "localhost" ,
9
- port : 3306 ,
10
- user : "root" ,
11
- password : mySqlKey ,
12
- database : "eventonica"
13
- } ) ;
1
+ const connection = require ( './connection' ) ;
2
+ const app = require ( './app' ) ;
14
3
15
4
const mySqlConnect = ( ) => {
16
5
connection . connect ( ( err ) => {
@@ -19,7 +8,7 @@ const mySqlConnect = () => {
19
8
console . log ( 'Welcome to Eventonica' )
20
9
console . log ( "connected as Administrator" ) ;
21
10
22
- app . initialize ( connection ) ;
11
+ app . startQuestion ( ( ) => { connection . end ( ) } ) ;
23
12
} )
24
13
}
25
14
You can’t perform that action at this time.
0 commit comments